@@ -84,22 +84,20 @@ def runParserTest(self, innerHTML, input, expected, errors, treeClass,
8484p = html5parser .HTMLParser (tree = treeClass ,
8585namespaceHTMLElements = namespaceHTMLElements )
8686except constants .DataLossWarning :
87- return
87+ return
8888
89- errors = [item .decode ("utf-8" )for item in errors ]
90-
9189try :
9290if innerHTML :
93- document = p .parseFragment (StringIO . StringIO ( input ) ,innerHTML )
91+ document = p .parseFragment (input ,innerHTML )
9492else :
9593try :
96- document = p .parse (StringIO . StringIO ( input ) )
94+ document = p .parse (input )
9795except constants .DataLossWarning :
9896return
9997except :
100- errorMsg = "\n " .join (["\n \n Input:" ,input ,"\n Expected:" ,expected ,
101- "\n Traceback:" ,traceback .format_exc ()])
102- self .assertTrue (False ,errorMsg )
98+ errorMsg = u "\n " .join ([u "\n \n Input:" ,input ,u "\n Expected:" ,expected ,
99+ u "\n Traceback:" ,traceback .format_exc ()])
100+ self .assertTrue (False ,errorMsg . encode ( "utf8" ) )
103101
104102output = convertTreeDump (p .tree .testSerializer (document ))
105103output = attrlist .sub (sortattrs ,output )
@@ -109,9 +107,9 @@ def runParserTest(self, innerHTML, input, expected, errors, treeClass,
109107if namespaceHTMLElements :
110108expected = namespaceExpected (r"\1<html \2>" ,expected )
111109
112- errorMsg = "\n " .join (["\n \n Input:" ,input ,"\n Expected:" ,expected ,
113- "\n Received:" ,output ])
114- self .assertEquals (expected ,output ,errorMsg .encode ("utf-8 " ))
110+ errorMsg = u "\n " .join ([u "\n \n Input:" ,input ,u "\n Expected:" ,expected ,
111+ u "\n Received:" ,output ])
112+ self .assertEquals (expected ,output ,errorMsg .encode ("utf8 " ))
115113errStr = [u"Line: %i Col: %i %s" % (line ,col ,
116114constants .E [errorcode ]% datavars if isinstance (datavars ,dict )else (datavars ,))for
117115 ((line ,col ),errorcode ,datavars )in p .errors ]
@@ -152,6 +150,8 @@ def testFunc(self, innerHTML=innerHTML, input=input,
152150testFunc .__name__ = "test_%s_%d_%s_%s" % (testName ,index + 1 ,treeName ,namespaceHTMLElements and "namespaced" or "no_html_namespace" )
153151setattr (TestCase ,testFunc .__name__ ,
154152testFunc )
153+ break
154+ break
155155
156156return unittest .TestLoader ().loadTestsFromTestCase (TestCase )
157157