Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(744)

Unified Diff: Lib/unittest/test/test_case.py

Issue 12038: assertEqual doesn't display newline differences quite well
Patch Set: Created 1 year, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/unittest/case.py ('k') | Lib/unittest/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/unittest/test/test_case.py Sat Jun 25 15:03:52 2011 +0200
+++ b/Lib/unittest/test/test_case.py Sun Jun 26 17:12:16 2011 +0200
@@ -756,6 +756,16 @@
self.assertEqual(str(cm.exception), '%r != %r' % (s1, s2))
self.assertEqual(s + 'a', s + 'a')
+ def testAssertEqualHumanReadableOutput(self):
+ # Issue #12038: Make the assertion error message more human redable
+ # for long strings.
+ s1 = "aaaaaa"
+ s2 = "abbbbb"
+ with self.assertRaises(self.failureException) as cm:
+ self.assertEqual(s1, s2)
+ self.assertIn("aa [truncated]... != 'ab [truncated]...",
+ str(cm.exception))
+
def testAssertCountEqual(self):
a = object()
self.assertCountEqual([1, 2, 3], [3, 2, 1])
« no previous file with comments | « Lib/unittest/case.py ('k') | Lib/unittest/util.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7