Skip to content

Commit c134584

Browse files
committed
Close python#22756: Improve the test output for some assertEqual tests.
These tests were undebuggable as written, and there's no testing fallacy involved in using the method we're testing to test the output of that method, so switch to that.
1 parent 3b6bd64 commit c134584

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎Lib/unittest/test/test_case.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,7 @@ def testAssertMultiLineEqual(self):
10751075
except self.failureException as e:
10761076
# need to remove the first line of the error message
10771077
error = str(e).split('\n', 1)[1]
1078-
1079-
# no fair testing ourself with ourself, and assertEqual is used for strings
1080-
# so can't use assertEqual either. Just use assertTrue.
1081-
self.assertTrue(sample_text_error == error)
1078+
self.assertEqual(sample_text_error, error)
10821079

10831080
def testAssertEqualSingleLine(self):
10841081
sample_text = "laden swallows fly slowly"
@@ -1092,8 +1089,9 @@ def testAssertEqualSingleLine(self):
10921089
try:
10931090
self.assertEqual(sample_text, revised_sample_text)
10941091
except self.failureException as e:
1092+
# need to remove the first line of the error message
10951093
error = str(e).split('\n', 1)[1]
1096-
self.assertTrue(sample_text_error == error)
1094+
self.assertEqual(sample_text_error, error)
10971095

10981096
def testAssertIsNone(self):
10991097
self.assertIsNone(None)

0 commit comments

Comments
 (0)