Skip to content

Commit 77843c6

Browse files
author
Michael Foord
committed
Fix unittest tests after previous commit.
1 parent f6a15c6 commit 77843c6

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/unittest/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ def assertMultiLineEqual(self, first, second, msg=None):
891891
'Second argument is not a string'))
892892

893893
if first != second:
894-
standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
894+
standardMsg = '%s != %s' % (safe_repr(first, True), safe_repr(second, True))
895895
diff = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
896896
second.splitlines(True)))
897897
standardMsg = self._truncateMessage(standardMsg, diff)

Lib/unittest/test/test_case.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def testAssertMultiLineEqual(self):
807807
A test case is the smallest unit of testing. [...] You may provide your
808808
own implementation that does not subclass from TestCase, of course.
809809
"""
810-
sample_text_error = b"""
810+
sample_text_error = b"""\
811811
- http://www.python.org/doc/2.3/lib/module-unittest.html
812812
? ^
813813
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
@@ -818,15 +818,18 @@ def testAssertMultiLineEqual(self):
818818
? +++++++++++++++++++++
819819
+ own implementation that does not subclass from TestCase, of course.
820820
"""
821-
821+
self.maxDiff = None
822822
for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
823823
try:
824824
self.assertMultiLineEqual(type_changer(sample_text),
825825
type_changer(revised_sample_text))
826826
except self.failureException, e:
827+
# need to remove the first line of the error message
828+
error = str(e).encode('utf8').split('\n', 1)[1]
829+
827830
# assertMultiLineEqual is hooked up as the default for
828831
# unicode strings - so we can't use it for this check
829-
self.assertTrue(sample_text_error == str(e).encode('utf8'))
832+
self.assertTrue(sample_text_error == error)
830833

831834
def testAssertIsNone(self):
832835
self.assertIsNone(None)

0 commit comments

Comments
 (0)