Skip to content

Commit 68d6f34

Browse files
committed
Remove last remanent of unittest from test_treewalkers.py
1 parent a75b120 commit 68d6f34

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

html5lib/tests/test_treewalkers.py

+23-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3-
import unittest
4-
5-
try:
6-
unittest.TestCase.assertEqual
7-
except AttributeError:
8-
unittest.TestCase.assertEqual = unittest.TestCase.assertEquals
9-
103
import pytest
114

125
from .support import treeTypes
@@ -24,30 +17,29 @@ def sortattrs(x):
2417
return "\n".join(lines)
2518

2619

27-
class TokenTestCase(unittest.TestCase):
28-
def test_all_tokens(self):
29-
expected = [
30-
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'html'},
31-
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'head'},
32-
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'head'},
33-
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'body'},
34-
{'data': 'a', 'type': 'Characters'},
35-
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'div'},
36-
{'data': 'b', 'type': 'Characters'},
37-
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'div'},
38-
{'data': 'c', 'type': 'Characters'},
39-
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'body'},
40-
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'html'}
41-
]
42-
for treeName, treeCls in sorted(treeTypes.items()):
43-
if treeCls is None:
44-
continue
45-
p = html5parser.HTMLParser(tree=treeCls["builder"])
46-
document = p.parse("<html><head></head><body>a<div>b</div>c</body></html>")
47-
document = treeCls.get("adapter", lambda x: x)(document)
48-
output = Lint(treeCls["walker"](document))
49-
for expectedToken, outputToken in zip(expected, output):
50-
self.assertEqual(expectedToken, outputToken)
20+
def test_all_tokens():
21+
expected = [
22+
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'html'},
23+
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'head'},
24+
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'head'},
25+
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'body'},
26+
{'data': 'a', 'type': 'Characters'},
27+
{'data': {}, 'type': 'StartTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'div'},
28+
{'data': 'b', 'type': 'Characters'},
29+
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'div'},
30+
{'data': 'c', 'type': 'Characters'},
31+
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'body'},
32+
{'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'html'}
33+
]
34+
for treeName, treeCls in sorted(treeTypes.items()):
35+
if treeCls is None:
36+
continue
37+
p = html5parser.HTMLParser(tree=treeCls["builder"])
38+
document = p.parse("<html><head></head><body>a<div>b</div>c</body></html>")
39+
document = treeCls.get("adapter", lambda x: x)(document)
40+
output = Lint(treeCls["walker"](document))
41+
for expectedToken, outputToken in zip(expected, output):
42+
assert expectedToken == outputToken
5143

5244

5345
def set_attribute_on_first_child(docfrag, name, value, treeName):

0 commit comments

Comments
 (0)