Skip to content

Commit dd117cc

Browse files
committed
Support pytest 4
Fixes #411
1 parent 4f92357 commit dd117cc

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

html5lib/tests/test_encoding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def test_encoding():
9999
for filename in get_data_files("encoding"):
100100
tests = _TestData(filename, b"data", encoding=None)
101101
for test in tests:
102-
yield (runParserEncodingTest, test[b'data'], test[b'encoding'])
103-
yield (runPreScanEncodingTest, test[b'data'], test[b'encoding'])
102+
runParserEncodingTest(test[b'data'], test[b'encoding'])
103+
runPreScanEncodingTest(test[b'data'], test[b'encoding'])
104104

105105

106106
# pylint:disable=wrong-import-position

html5lib/tests/test_sanitizer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ def test_sanitizer():
6767
'tfoot', 'th', 'thead', 'tr', 'select']:
6868
continue # TODO
6969
if tag_name == 'image':
70-
yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
70+
runSanitizerTest("test_should_allow_%s_tag" % tag_name,
7171
"<img title=\"1\"/>foo &lt;bad&gt;bar&lt;/bad&gt; baz",
7272
"<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name, tag_name))
7373
elif tag_name == 'br':
74-
yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
74+
runSanitizerTest("test_should_allow_%s_tag" % tag_name,
7575
"<br title=\"1\"/>foo &lt;bad&gt;bar&lt;/bad&gt; baz<br/>",
7676
"<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name, tag_name))
7777
elif tag_name in constants.voidElements:
78-
yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
78+
runSanitizerTest("test_should_allow_%s_tag" % tag_name,
7979
"<%s title=\"1\"/>foo &lt;bad&gt;bar&lt;/bad&gt; baz" % tag_name,
8080
"<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name, tag_name))
8181
else:
82-
yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name,
82+
runSanitizerTest("test_should_allow_%s_tag" % tag_name,
8383
"<%s title=\"1\">foo &lt;bad&gt;bar&lt;/bad&gt; baz</%s>" % (tag_name, tag_name),
8484
"<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name, tag_name))
8585

@@ -93,15 +93,15 @@ def test_sanitizer():
9393
attribute_value = 'foo'
9494
if attribute_name in sanitizer.attr_val_is_uri:
9595
attribute_value = '%s://sub.domain.tld/path/object.ext' % sanitizer.allowed_protocols[0]
96-
yield (runSanitizerTest, "test_should_allow_%s_attribute" % attribute_name,
96+
runSanitizerTest("test_should_allow_%s_attribute" % attribute_name,
9797
"<p %s=\"%s\">foo &lt;bad&gt;bar&lt;/bad&gt; baz</p>" % (attribute_name, attribute_value),
9898
"<p %s='%s'>foo <bad>bar</bad> baz</p>" % (attribute_name, attribute_value))
9999

100100
for protocol in sanitizer.allowed_protocols:
101101
rest_of_uri = '//sub.domain.tld/path/object.ext'
102102
if protocol == 'data':
103103
rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
104-
yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol,
104+
runSanitizerTest("test_should_allow_uppercase_%s_uris" % protocol,
105105
"<img src=\"%s:%s\">foo</a>" % (protocol, rest_of_uri),
106106
"""<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
107107

@@ -110,7 +110,7 @@ def test_sanitizer():
110110
if protocol == 'data':
111111
rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
112112
protocol = protocol.upper()
113-
yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol,
113+
runSanitizerTest("test_should_allow_uppercase_%s_uris" % protocol,
114114
"<img src=\"%s:%s\">foo</a>" % (protocol, rest_of_uri),
115115
"""<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
116116

html5lib/tests/test_serializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ def test_serializer():
222222
with open(filename) as fp:
223223
tests = json.load(fp)
224224
for test in tests['tests']:
225-
yield runSerializerTest, test["input"], test["expected"], test.get("options", {})
225+
runSerializerTest(test["input"], test["expected"], test.get("options", {}))

html5lib/tests/test_stream.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,10 @@ def test_invalid_codepoints(inp, num):
308308
("'\\uD800\\uD800\\uD800'", 3),
309309
("'a\\uD800a\\uD800a\\uD800a'", 3),
310310
("'\\uDFFF\\uDBFF'", 2),
311-
pytest.mark.skipif(sys.maxunicode == 0xFFFF,
312-
("'\\uDBFF\\uDFFF'", 2),
313-
reason="narrow Python")])
311+
pytest.param(
312+
"'\\uDBFF\\uDFFF'", 2,
313+
mark=pytest.mark.skipif(sys.maxunicode == 0xFFFF,
314+
reason="narrow Python"))])
314315
def test_invalid_codepoints_surrogates(inp, num):
315316
inp = eval(inp) # pylint:disable=eval-used
316317
fp = StringIO(inp)

html5lib/tests/test_treewalkers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_treewalker_six_mix():
9999

100100
for tree in sorted(treeTypes.items()):
101101
for intext, attrs, expected in sm_tests:
102-
yield runTreewalkerEditTest, intext, expected, attrs, tree
102+
runTreewalkerEditTest(intext, expected, attrs, tree)
103103

104104

105105
@pytest.mark.parametrize("tree,char", itertools.product(sorted(treeTypes.items()), ["x", "\u1234"]))

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tox
44

55
flake8<3.0
66

7-
pytest==3.2.5
7+
pytest>=4.3,<4.4
88
coverage
99
pytest-expect>=1.1,<2.0
1010
mock

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py27,py34,py35,py36,pypy}-{base,six19,optional}
2+
envlist = {py27,py34,py35,py36,py37,py38,pypy}-{base,six19,optional}
33

44
[testenv]
55
deps =

0 commit comments

Comments
 (0)