Skip to content

Commit

Permalink
Added an expanded contribution guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Oct 21, 2017
1 parent 726cb82 commit 9e219bc
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 32 deletions.
2 changes: 0 additions & 2 deletions MANIFEST.in
Expand Up @@ -2,8 +2,6 @@ include CONTRIBUTING.md
include README.rst
include AUTHORS
include LICENSE
include requirements*.txt
include tox.ini
recursive-include colosseum *.py
recursive-include docs *.bat
recursive-include docs *.py
Expand Down
396 changes: 393 additions & 3 deletions docs/how-to/contribute.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/how-to/index.rst
Expand Up @@ -10,5 +10,5 @@ How-to guides are recipes that take the user through steps in key subjects. They
:maxdepth: 1
:glob:

Get started <get-started>
Contribute to Toga <contribute>
get-started
contribute
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/screenshots/w3c-test-suite-raw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/how-to/screenshots/w3c-test-suite.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 46 additions & 25 deletions tests/utils.py
Expand Up @@ -155,13 +155,14 @@ def layout_node(self, node):
root = TestNode(style=CSS(display=BLOCK), children=[node])
layout(self.display, root)

def assertLayout(self, node, reference):
def assertLayout(self, node, reference, extra=''):
self.assertEqual(
layout_summary(node),
reference,
'\nExpected:\n{}Actual:\n{}'.format(
'\n\nExpected:\n{}Actual:\n{}{}'.format(
output_layout(reference),
output_layout(layout_summary(node))
output_layout(layout_summary(node)),
extra
)
)

Expand All @@ -174,28 +175,41 @@ def find_tests(cls, test_filename, group):
ref_dir = os.path.join(dirname, 'ref')

# Read the not_implemented file.
expected_failures = set()
not_implemented_file = os.path.join(dirname, 'not_implemented')
try:
with open(not_implemented_file) as f:
not_implemented = set(
expected_failures.update({
'test_' + line.strip().replace('-', '_')
for line in f
if line.strip()
)
})
except IOError:
not_implemented = set()
pass

# Read the ignore file.
ignore_file = os.path.join(dirname, 'ignore')
not_compliant = os.path.join(dirname, 'not_compliant')
try:
with open(ignore_file) as f:
ignore = set(
with open(not_compliant) as f:
expected_failures.update({
'test_' + line.strip().replace('-', '_')
for line in f
if line.strip()
)
})
except IOError:
ignore = set()
pass

# Read the not_valid test file.
ignore = set()
not_valid_file = os.path.join(dirname, 'not_valid')
try:
with open(not_valid_file) as f:
ignore.update({
'test_' + line.strip().replace('-', '_')
for line in f
if line.strip()
})
except IOError:
pass

# Closure for building test cases for a given input file.
def make_test(test_dir, filename):
Expand All @@ -211,14 +225,30 @@ def make_test(test_dir, filename):
with open(os.path.join(ref_dir, filename)) as f:
reference = json.load(f)

extra = []
if input_data['help']:
extra.append('\n'.join('See {}'.format(h) for h in input_data['help']))
extra.append('')

extra.append(
'Test: http://test.csswg.org/harness/test/{}_dev/single/{}/'.format(
css_test_module,
css_test_name
)
)

# The actual test method. Builds a document, lays it out,
# and checks against the reference rendering.
def test_method(self):
root = build_document(input_data['test_case'])

layout(self.display, root, standard=HTML4)

self.assertLayout(root, clean_reference(reference))
self.assertLayout(
root,
clean_reference(reference),
'\n' + '\n'.join(extra)
)

# Annotate the method with any helper text.
doc = []
Expand All @@ -228,22 +258,13 @@ def test_method(self):
doc.append('Test ' + os.path.splitext(filename)[0].replace('-', '_'))

doc.append('')
if input_data['help']:
doc.append('\n'.join('See {}'.format(h) for h in input_data['help']))

doc.append('')
doc.append(
'Test: http://test.csswg.org/harness/test/{}_dev/single/{}/'.format(
css_test_module,
css_test_name
)
)
doc.extend(extra)

test_method.__doc__ = '\n'.join(doc)

# If the method is on the known not_implemented list,
# If the method is on the expected_failures list,
# decorate the method.
if test_name in not_implemented:
if test_name in expected_failures:
test_method = expectedFailure(test_method)

return test_name, test_method
Expand Down

0 comments on commit 9e219bc

Please sign in to comment.