Commits

jpellerin  committed 78fad2d

Fixed test failure under 2.4

  • Participants
  • Parent commits 383020c

Comments (0)

Files changed (1)

File unit_tests/test_xunit.py

         f = open(self.xmlfile, 'r')
         return f.read()
         f.close()
-            
+
     def test_addFailure(self):
         test = mktest()
         self.x.startTest(test)
             raise AssertionError("one is not 'equal' to two")
         except AssertionError:
             some_err = sys.exc_info()
-            
+
         self.x.addFailure(test, some_err)
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             eq_(tree.attrib['name'], "nosetests")
             eq_(tree.attrib['errors'], "0")
             eq_(tree.attrib['failures'], "1")
             eq_(tree.attrib['skip'], "0")
-        
+
             tc = tree.find("testcase")
             eq_(tc.attrib['classname'], "test_xunit.TC")
             eq_(tc.attrib['name'], "runTest")
             assert int(tc.attrib['time']) >= 0
-        
+
             err = tc.find("failure")
             eq_(err.attrib['type'], "exceptions.AssertionError")
             err_lines = err.text.strip().split("\n")
             eq_(err_lines[0], 'Traceback (most recent call last):')
             eq_(err_lines[-1], 'AssertionError: one is not \'equal\' to two')
             eq_(err_lines[-2], '    raise AssertionError("one is not \'equal\' to two")')
-        else:            
+        else:
             # this is a dumb test for 2.4-
             assert '<?xml version="1.0" encoding="UTF-8"?>' in result
             assert '<testsuite name="nosetests" tests="1" errors="0" failures="1" skip="0">' in result
             assert '<testcase classname="test_xunit.TC" name="runTest"' in result
-            assert '<failure type="exceptions.AssertionError">' in result
-            assert 'AssertionError: one is not &#39;equal&#39; to two' in result
-            assert 'AssertionError(&quot;one is not &#39;equal&#39; to two&quot;)' in result
+            assert '<failure type="exceptions.AssertionError"' in result
+            assert "AssertionError: one is not 'equal' to two" in result
+            assert "AssertionError(\"one is not 'equal' to two\")" in result
             assert '</failure></testcase></testsuite>' in result
-            
+
     def test_addFailure_early(self):
         test = mktest()
         try:
             raise AssertionError("one is not equal to two")
         except AssertionError:
             some_err = sys.exc_info()
-        
+
         # add failure without startTest, due to custom TestResult munging?
         self.x.addFailure(test, some_err)
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             tc = tree.find("testcase")
             assert '<?xml version="1.0" encoding="UTF-8"?>' in result
             assert ('<testcase classname="test_xunit.TC" '
                     'name="runTest" time="0">') in result
-    
+
     def test_addError(self):
         test = mktest()
         self.x.startTest(test)
             raise RuntimeError("some error happened")
         except RuntimeError:
             some_err = sys.exc_info()
-            
+
         self.x.addError(test, some_err)
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             eq_(tree.attrib['name'], "nosetests")
             eq_(tree.attrib['errors'], "1")
             eq_(tree.attrib['failures'], "0")
             eq_(tree.attrib['skip'], "0")
-        
+
             tc = tree.find("testcase")
             eq_(tc.attrib['classname'], "test_xunit.TC")
             eq_(tc.attrib['name'], "runTest")
             assert int(tc.attrib['time']) >= 0
-        
+
             err = tc.find("error")
             eq_(err.attrib['type'], "exceptions.RuntimeError")
             err_lines = err.text.strip().split("\n")
             assert '<?xml version="1.0" encoding="UTF-8"?>' in result
             assert '<testsuite name="nosetests" tests="1" errors="1" failures="0" skip="0">' in result
             assert '<testcase classname="test_xunit.TC" name="runTest"' in result
-            assert '<error type="exceptions.RuntimeError">' in result
+            assert '<error type="exceptions.RuntimeError"' in result
             assert 'RuntimeError: some error happened' in result
             assert '</error></testcase></testsuite>' in result
-    
+
     def test_addError_early(self):
         test = mktest()
         try:
             raise RuntimeError("some error happened")
         except RuntimeError:
             some_err = sys.exc_info()
-        
+
         # call addError without startTest
         # which can happen if setup() raises an error
         self.x.addError(test, some_err)
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             tc = tree.find("testcase")
             assert '<?xml version="1.0" encoding="UTF-8"?>' in result
             assert ('<testcase classname="test_xunit.TC" '
                     'name="runTest" time="0">') in result
-        
+
     def test_addSuccess(self):
         test = mktest()
         self.x.startTest(test)
         self.x.addSuccess(test, (None,None,None))
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             eq_(tree.attrib['name'], "nosetests")
             eq_(tree.attrib['errors'], "0")
             eq_(tree.attrib['failures'], "0")
             eq_(tree.attrib['skip'], "0")
-        
+
             tc = tree.find("testcase")
             eq_(tc.attrib['classname'], "test_xunit.TC")
             eq_(tc.attrib['name'], "runTest")
             assert '<testsuite name="nosetests" tests="1" errors="0" failures="0" skip="0">' in result
             assert '<testcase classname="test_xunit.TC" name="runTest"' in result
             assert '</testsuite>' in result
-    
+
     def test_addSuccess_early(self):
         test = mktest()
         # call addSuccess without startTest
         # which can happen (?) -- did happen with JsLint plugin
         self.x.addSuccess(test, (None,None,None))
-        
+
         result = self.get_xml_report()
         print result
-        
+
         if self.ET:
             tree = self.ET.fromstring(result)
             tc = tree.find("testcase")
             assert '<?xml version="1.0" encoding="UTF-8"?>' in result
             assert ('<testcase classname="test_xunit.TC" '
                     'name="runTest" time="0" />') in result
-        
+