[Patches] [ python-Patches-725569 ] Improved output for unittest failUnlessEqual
SourceForge.net
noreply@sourceforge.net
Tue, 22 Apr 2003 03:33:41 -0700
Patches item #725569, was opened at 2003-04-22 10:33
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=725569&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Duncan Booth (duncanb)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improved output for unittest failUnlessEqual
Initial Comment:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=725569&group_id=5470