Commit c1345840 authored by Robert Collins's avatar Robert Collins

Close #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.
parent 3b6bd645
...@@ -1075,10 +1075,7 @@ test case ...@@ -1075,10 +1075,7 @@ test case
except self.failureException as e: except self.failureException as e:
# need to remove the first line of the error message # need to remove the first line of the error message
error = str(e).split('\n', 1)[1] error = str(e).split('\n', 1)[1]
self.assertEqual(sample_text_error, error)
# no fair testing ourself with ourself, and assertEqual is used for strings
# so can't use assertEqual either. Just use assertTrue.
self.assertTrue(sample_text_error == error)
def testAssertEqualSingleLine(self): def testAssertEqualSingleLine(self):
sample_text = "laden swallows fly slowly" sample_text = "laden swallows fly slowly"
...@@ -1092,8 +1089,9 @@ test case ...@@ -1092,8 +1089,9 @@ test case
try: try:
self.assertEqual(sample_text, revised_sample_text) self.assertEqual(sample_text, revised_sample_text)
except self.failureException as e: except self.failureException as e:
# need to remove the first line of the error message
error = str(e).split('\n', 1)[1] error = str(e).split('\n', 1)[1]
self.assertTrue(sample_text_error == error) self.assertEqual(sample_text_error, error)
def testAssertIsNone(self): def testAssertIsNone(self):
self.assertIsNone(None) self.assertIsNone(None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment