This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author duncanb
Recipients
Date 2003-04-22.10:33:41
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The failUnlessEqual method in unittest.TestCase 
doesn't handle well the case where the objects being 
compared have a long string representation. The 
whole repr for each object is printed no matter how 
long, and no indication is given of where any 
differences occur.

This patch uses difflib on long representations to 
provide a short output that highlights where the first 
difference actually is. It also limits the output for each 
value to fit on a single line (with the differences 
indicated on the line following).

e.g.
FAIL: test_failunlessEqual4 (__main__.Test)
----------------------------------------------------------------------
TestFailed: failUnlessEqual
{'A': 65, 'C': 67, ...0, 'P ': 0, 'R': 82, 'U': 85, 'T': 84, 'W': 
87, 'V': 8...
                   ...    ^^   ^                                            ...
{'A': 65, 'C': 67, ...0, 'S': 83, 'R': 82, 'U': 85, 'T': 84, 'W': 
87, 'V': 8...
                   ...    ^   ^^                                            ...
  File "F:\temp\test.py", line 59, in test_failunlessEqual4
    self.failUnlessEqual(d2, d1)

----------------------------------------------------------------------

The attached file contains the changes, assuming that 
patch "722638 Better output for unittest" has already 
been applied.
History
Date User Action Args
2007-08-23 15:22:31adminlinkissue725569 messages
2007-08-23 15:22:31admincreate