Fix error message for comparing single line strings in unittest.TestCase.assertEqual.

Issue 9174.
This commit is contained in:
Michael Foord 2010-07-10 13:52:22 +00:00
parent 0425a8ea72
commit c653ce313f
2 changed files with 23 additions and 3 deletions

View file

@ -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)