summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-07-10 13:52:22 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-07-10 13:52:22 (GMT)
commitc653ce313f6781d27852a3f3552a0295c1a1fa6a (patch)
tree5786116363ab341638faf74c5c3fc0f6a59f6947 /Lib/unittest/test
parent0425a8ea729617a74ab343909687d98216d25524 (diff)
downloadcpython-c653ce313f6781d27852a3f3552a0295c1a1fa6a.zip
cpython-c653ce313f6781d27852a3f3552a0295c1a1fa6a.tar.gz
cpython-c653ce313f6781d27852a3f3552a0295c1a1fa6a.tar.bz2
Fix error message for comparing single line strings in unittest.TestCase.assertEqual.
Issue 9174.
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/test_case.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
index 00883c9..1800f2e 100644
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/unittest/test/test_case.py
@@ -841,6 +841,21 @@ test case
# so can't use assertEqual either. Just use assertTrue.
self.assertTrue(sample_text_error == error)
+ def testAsertEqualSingleLine(self):
+ sample_text = "laden swallows fly slowly"
+ revised_sample_text = "unladen swallows fly quickly"
+ sample_text_error = """\
+- laden swallows fly slowly
+? ^^^^
++ unladen swallows fly quickly
+? ++ ^^^^^
+"""
+ try:
+ self.assertEqual(sample_text, revised_sample_text)
+ except self.failureException as e:
+ error = str(e).split('\n', 1)[1]
+ self.assertTrue(sample_text_error == error)
+
def testAssertIsNone(self):
self.assertIsNone(None)
self.assertRaises(self.failureException, self.assertIsNone, False)