diff options
| author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-07-10 13:51:42 (GMT) |
|---|---|---|
| committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-07-10 13:51:42 (GMT) |
| commit | 94f071c7158e8751063a9692bc86a4122b0a717a (patch) | |
| tree | f9db08c85a447f75d50607739e8dddd43c11f47b /Lib/unittest/test/test_case.py | |
| parent | 8e93f4e791d9e0fab7a40d1c95f5071f166f8390 (diff) | |
| download | cpython-94f071c7158e8751063a9692bc86a4122b0a717a.zip cpython-94f071c7158e8751063a9692bc86a4122b0a717a.tar.gz cpython-94f071c7158e8751063a9692bc86a4122b0a717a.tar.bz2 | |
Fix error message for comparing single line strings in unittest.TestCase.assertEqual.
Issue 9174
Diffstat (limited to 'Lib/unittest/test/test_case.py')
| -rw-r--r-- | Lib/unittest/test/test_case.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index a395fe0..4e9dfc6 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -874,6 +874,21 @@ test case # unicode strings - so we can't use it for this check self.assertTrue(sample_text_error == error) + def testAsertEqualSingleLine(self): + sample_text = u"laden swallows fly slowly" + revised_sample_text = u"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) |
