44import StringIO
55import unittest
66import warnings
7+ import re
78
89warnings .simplefilter ("error" )
910
6768def convertTreeDump (data ):
6869 return "\n " .join (convert (3 )(data ).split ("\n " )[1 :])
6970
70- import re
71- attrlist = re .compile (r"^(\s+)\w+(?:\s\w+)?=.*(?:\n\1\w+(?:\s\w+)?=.*)+" ,re .M )
72- def sortattrs (x ):
73- lines = x .group (0 ).split ("\n " )
74- lines .sort ()
75- return "\n " .join (lines )
7671namespaceExpected = re .compile (r"^(\s*)<(\S+)>" , re .M ).sub
7772
7873class TestCase (unittest .TestCase ):
@@ -100,10 +95,8 @@ def runParserTest(self, innerHTML, input, expected, errors, treeClass,
10095 self .assertTrue (False , errorMsg .encode ("utf8" ))
10196
10297 output = convertTreeDump (p .tree .testSerializer (document ))
103- output = attrlist .sub (sortattrs , output )
10498
10599 expected = convertExpected (expected )
106- expected = attrlist .sub (sortattrs , expected )
107100 if namespaceHTMLElements :
108101 expected = namespaceExpected (r"\1<html \2>" , expected )
109102
@@ -125,8 +118,6 @@ def buildTestSuite():
125118
126119 for treeName , treeCls in treeTypes .iteritems ():
127120 files = html5lib_test_files ('tree-construction' )
128- #files = [f for f in files if
129- # not f.split(".")[-2][-2:] in ("s9", "10", "11", "12")] #skip namespace tests for now
130121 for filename in files :
131122 testName = os .path .basename (filename ).replace (".dat" ,"" )
132123
@@ -151,7 +142,6 @@ def testFunc(self, innerHTML=innerHTML, input=input,
151142 setattr (TestCase , testFunc .__name__ ,
152143 testFunc )
153144 break
154- break
155145
156146 return unittest .TestLoader ().loadTestsFromTestCase (TestCase )
157147
0 commit comments