summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-06-05 13:14:43 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-06-05 13:14:43 (GMT)
commitcb11b251a09fe141b3ded25744b70caea51f6551 (patch)
tree464430d5658a90f4e1e4bd566ac8fdd927e7c9e7 /Lib/unittest/case.py
parent02ff2100d3935bbdb9ea0000b667982aecc9d6ee (diff)
downloadcpython-cb11b251a09fe141b3ded25744b70caea51f6551.zip
cpython-cb11b251a09fe141b3ded25744b70caea51f6551.tar.gz
cpython-cb11b251a09fe141b3ded25744b70caea51f6551.tar.bz2
Merged revisions 81747 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81747 | michael.foord | 2010-06-05 13:58:39 +0100 (Sat, 05 Jun 2010) | 1 line unittest.TestCase.assertDictEqual and assertMultilineEqual provide better default failure messages in the event of long diffs. ........
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index a8b2f4d..fca7e19 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -811,10 +811,11 @@ class TestCase(object):
self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
if d1 != d2:
+ standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
diff = ('\n' + '\n'.join(difflib.ndiff(
pprint.pformat(d1).splitlines(),
pprint.pformat(d2).splitlines())))
- standardMsg = self._truncateMessage('', diff)
+ standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
def assertDictContainsSubset(self, expected, actual, msg=None):
@@ -931,9 +932,10 @@ class TestCase(object):
'Second argument is not a string'))
if first != second:
+ standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
diff = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
second.splitlines(True)))
- standardMsg = self._truncateMessage('', diff)
+ standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
def assertLess(self, a, b, msg=None):