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

This commit is contained in:
Michael Foord 2010-12-03 00:53:09 +00:00
parent 1203720ffb
commit 5074df623b
4 changed files with 7 additions and 4 deletions

View File

@ -1305,8 +1305,8 @@ Test cases
to ``True`` allows you to have a custom error message in addition to the to ``True`` allows you to have a custom error message in addition to the
normal one. normal one.
This attribute defaults to ``False``, meaning that a custom message passed This attribute defaults to ``True``. If set to False then a custom message
to an assert method will silence the normal message. passed to an assert method will silence the normal message.
The class setting can be overridden in individual tests by assigning an The class setting can be overridden in individual tests by assigning an
instance attribute to ``True`` or ``False`` before calling the assert methods. instance attribute to ``True`` or ``False`` before calling the assert methods.

View File

@ -245,7 +245,7 @@ class TestCase(object):
# objects used in assert methods) will be printed on failure in *addition* # objects used in assert methods) will be printed on failure in *addition*
# to any explicit message passed. # to any explicit message passed.
longMessage = False longMessage = True
# This attribute sets the maximum length of a diff in failure messages # 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 # by assert methods using difflib. It is looked up as an instance attribute

View File

@ -127,7 +127,7 @@ class TestLongMessage(unittest.TestCase):
self.testableFalse = TestableTestFalse('testTest') self.testableFalse = TestableTestFalse('testTest')
def testDefault(self): def testDefault(self):
self.assertFalse(unittest.TestCase.longMessage) self.assertTrue(unittest.TestCase.longMessage)
def test_formatMsg(self): def test_formatMsg(self):
self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo") self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")

View File

@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
Core and Builtins 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 #9915: Speed up sorting with a key.
- Issue #9333: Expose os.symlink only when the SeCreateSymbolicLinkPrivilege - Issue #9333: Expose os.symlink only when the SeCreateSymbolicLinkPrivilege