[Python-checkins] cpython: Close #22756: Improve the test output for some assertEqual tests.

robert.collins python-checkins at python.org
Wed Oct 29 20:23:09 CET 2014


https://hg.python.org/cpython/rev/2f17d71ec53f
changeset:   93257:2f17d71ec53f
user:        Robert Collins <rbtcollins at hp.com>
date:        Thu Oct 30 08:16:28 2014 +1300
summary:
  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.

files:
  Lib/unittest/test/test_case.py |  8 +++-----
  1 files changed, 3 insertions(+), 5 deletions(-)


diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/unittest/test/test_case.py
@@ -1075,10 +1075,7 @@
         except self.failureException as e:
             # need to remove the first line of the error message
             error = str(e).split('\n', 1)[1]
-
-            # 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)
+            self.assertEqual(sample_text_error, error)
 
     def testAssertEqualSingleLine(self):
         sample_text = "laden swallows fly slowly"
@@ -1092,8 +1089,9 @@
         try:
             self.assertEqual(sample_text, revised_sample_text)
         except self.failureException as e:
+            # need to remove the first line of the error message
             error = str(e).split('\n', 1)[1]
-            self.assertTrue(sample_text_error == error)
+            self.assertEqual(sample_text_error, error)
 
     def testAssertIsNone(self):
         self.assertIsNone(None)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list