[Python-checkins] r81753 - in python/trunk/Lib/unittest: case.py test/test_case.py

michael.foord python-checkins at python.org
Sat Jun 5 15:48:27 CEST 2010


Author: michael.foord
Date: Sat Jun  5 15:48:27 2010
New Revision: 81753

Log:
Fix unittest tests after previous commit.

Modified:
   python/trunk/Lib/unittest/case.py
   python/trunk/Lib/unittest/test/test_case.py

Modified: python/trunk/Lib/unittest/case.py
==============================================================================
--- python/trunk/Lib/unittest/case.py	(original)
+++ python/trunk/Lib/unittest/case.py	Sat Jun  5 15:48:27 2010
@@ -891,7 +891,7 @@
                 'Second argument is not a string'))
 
         if first != second:
-            standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
+            standardMsg = '%s != %s' % (safe_repr(first, True), safe_repr(second, True))
             diff = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
                                                        second.splitlines(True)))
             standardMsg = self._truncateMessage(standardMsg, diff)

Modified: python/trunk/Lib/unittest/test/test_case.py
==============================================================================
--- python/trunk/Lib/unittest/test/test_case.py	(original)
+++ python/trunk/Lib/unittest/test/test_case.py	Sat Jun  5 15:48:27 2010
@@ -807,7 +807,7 @@
     A test case is the smallest unit of testing. [...] You may provide your
     own implementation that does not subclass from TestCase, of course.
 """
-        sample_text_error = b"""
+        sample_text_error = b"""\
 - http://www.python.org/doc/2.3/lib/module-unittest.html
 ?                             ^
 + http://www.python.org/doc/2.4.1/lib/module-unittest.html
@@ -818,15 +818,18 @@
 ?                                                       +++++++++++++++++++++
 +     own implementation that does not subclass from TestCase, of course.
 """
-
+        self.maxDiff = None
         for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
             try:
                 self.assertMultiLineEqual(type_changer(sample_text),
                                           type_changer(revised_sample_text))
             except self.failureException, e:
+                # need to remove the first line of the error message
+                error = str(e).encode('utf8').split('\n', 1)[1]
+
                 # assertMultiLineEqual is hooked up as the default for
                 # unicode strings - so we can't use it for this check
-                self.assertTrue(sample_text_error == str(e).encode('utf8'))
+                self.assertTrue(sample_text_error == error)
 
     def testAssertIsNone(self):
         self.assertIsNone(None)


More information about the Python-checkins mailing list