8000 Change test_treewalkers to support the new test case format · html5lib/html5lib-python@9066d8a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9066d8a

Browse files
committed
Change test_treewalkers to support the new test case format
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40844
1 parent cda0b54 commit 9066d8a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/test_treewalkers.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import StringIO
44
import unittest
55

6-
from support import html5lib_test_files
6+
from support import html5lib_test_files, TestData
77

88
from html5lib import html5parser, treewalkers, treebuilders
99
from html5lib.filters.lint import Filter as LintFilter, LintError
1010

11-
from test_parser import parseTestcase
11+
from test_parser import convertExpected
1212

1313
def PullDOMAdapter(node):
1414
from xml.dom import Node
@@ -209,7 +209,7 @@ def runTest(self, innerHTML, input, expected, errors, treeClass):
209209
try:
210210
output = convertTokens(LintFilter(treeClass["walker"](document)))
211211
output = attrlist.sub(sortattrs, output)
212-
expected = attrlist.sub(sortattrs, expected)
212+
expected = attrlist.sub(sortattrs, convertExpected(expected))
213213
self.assertEquals(expected, output, "\n".join([
214214
"", "Input:", input,
215215
"", "Expected:", expected,
@@ -228,16 +228,14 @@ def buildTestSuite():
228228
testName = os.path.basename(filename).replace(".dat","")
229229
if testName == "tests5": continue # TODO
230230

231-
f = open(filename)
232-
tests = f.read().split("#data\n")
231+
tests = TestData(filename, ("data", "errors", "document-fragment",
232+
"document"))
233233

234234
for index, test in enumerate(tests):
235-
if test == "": continue
236-
test = "#data\n" + test
237-
innerHTML, input, expected, errors = parseTestcase(test)
238-
239-
def testFunc(self, innerHTML=innerHTML, input=input,
240-
expected=expected, errors=errors, treeCls=treeCls):
235+
errors = test['errors'].split("\n")
236+
def testFunc(self, innerHTML=test['document-fragment'],
237+
input=test['data'], expected=test['document'],
238+
errors=errors, treeCls=treeCls):
241239
self.runTest(innerHTML, input, expected, errors, treeCls)
242240
setattr(TestCase, "test_%s_%d_%s" % (testName,index+1,treeName),
243241
testFunc)

0 commit comments

Comments
 (0)
0