From: Michael Foord Date: Fri, 3 Dec 2010 00:53:09 +0000 (+0000) Subject: Issue 7911: unittest.TestCase.longMessage defaults to True for improved failure messa... X-Git-Tag: v3.2b1~119 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5074df623b70cf196965af332092a6f98a035c3d;p=thirdparty%2FPython%2Fcpython.git Issue 7911: unittest.TestCase.longMessage defaults to True for improved failure messages by default --- diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index db6c53fc0958..2b9c2be1a3c2 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -1305,8 +1305,8 @@ Test cases 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. diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index bb337f1da2fc..227879cb6d43 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -245,7 +245,7 @@ class TestCase(object): # 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 diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py index 0ee7edbd041d..69572eee1902 100644 --- a/Lib/unittest/test/test_assertions.py +++ b/Lib/unittest/test/test_assertions.py @@ -127,7 +127,7 @@ class TestLongMessage(unittest.TestCase): 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") diff --git a/Misc/NEWS b/Misc/NEWS index b0975f8f6c24..e856c6de5af7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1? 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