[Python-checkins] r86944 - in python/branches/py3k: Doc/library/unittest.rst Lib/unittest/case.py Lib/unittest/test/test_assertions.py Misc/NEWS

michael.foord python-checkins at python.org
Fri Dec 3 01:53:09 CET 2010


Author: michael.foord
Date: Fri Dec  3 01:53:09 2010
New Revision: 86944

Log:
Issue 7911: unittest.TestCase.longMessage defaults to True for improved failure messages by default

Modified:
   python/branches/py3k/Doc/library/unittest.rst
   python/branches/py3k/Lib/unittest/case.py
   python/branches/py3k/Lib/unittest/test/test_assertions.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k/Doc/library/unittest.rst	(original)
+++ python/branches/py3k/Doc/library/unittest.rst	Fri Dec  3 01:53:09 2010
@@ -1305,8 +1305,8 @@
       to ``True`` allows you to have a custom error message in addition to the
       normal one.
 
-      This attribute defaults to ``False``, meaning that a custom message passed
-      to an assert method will silence the normal message.
+      This attribute defaults to ``True``. If set to False then a custom message
+      passed to an assert method will silence the normal message.
 
       The class setting can be overridden in individual tests by assigning an
       instance attribute to ``True`` or ``False`` before calling the assert methods.

Modified: python/branches/py3k/Lib/unittest/case.py
==============================================================================
--- python/branches/py3k/Lib/unittest/case.py	(original)
+++ python/branches/py3k/Lib/unittest/case.py	Fri Dec  3 01:53:09 2010
@@ -245,7 +245,7 @@
     # objects used in assert methods) will be printed on failure in *addition*
     # to any explicit message passed.
 
-    longMessage = False
+    longMessage = True
 
     # This attribute sets the maximum length of a diff in failure messages
     # by assert methods using difflib. It is looked up as an instance attribute

Modified: python/branches/py3k/Lib/unittest/test/test_assertions.py
==============================================================================
--- python/branches/py3k/Lib/unittest/test/test_assertions.py	(original)
+++ python/branches/py3k/Lib/unittest/test/test_assertions.py	Fri Dec  3 01:53:09 2010
@@ -127,7 +127,7 @@
         self.testableFalse = TestableTestFalse('testTest')
 
     def testDefault(self):
-        self.assertFalse(unittest.TestCase.longMessage)
+        self.assertTrue(unittest.TestCase.longMessage)
 
     def test_formatMsg(self):
         self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Dec  3 01:53:09 2010
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue 7911: `unittest.TestCase.longMessage` defaults to True for improved
+  failure messages by default. Patch by Mark Roddy.
+  
 - Issue #9915: Speed up sorting with a key.
 
 - Issue #9333: Expose os.symlink only when the SeCreateSymbolicLinkPrivilege


More information about the Python-checkins mailing list