[Patches] [ python-Patches-722638 ] Better output for unittest
SourceForge.net
noreply@sourceforge.net
Tue, 06 May 2003 12:52:15 -0700
Patches item #722638, was opened at 2003-04-16 13:49
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=722638&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Nobody/Anonymous (nobody)
Summary: Better output for unittest
Initial Comment:
This patch enables more useful output for unittests: If
a test crashes (raises an unexpected exception), a full
traceback is printed.
If a test failes, the output is something like this:
========================================
FAIL: test_failUnlessEqual (__main__.FailingTests)
----------------------------------------------------------------------
TestFailed: 0 != 1
File "xunit.py", line 12, in test_failUnlessEqual
self.failUnlessEqual(self.a, self.b)
========================================
Before, this was printed:
========================================
FAIL: test_failIfEqual (__main__.FailingTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "xunit.py", line 15, in test_failIfEqual
self.failIfEqual(self.a, self.a)
File "c:\python23\lib\unittest.py", line 300, in
failIfEqual
raise self.failureException, \
AssertionError: 0 == 0
========================================
If needed, I can upload the test script I use, together
with the results before and after the patch.
This has shortly been discussed on c.l.p, response was
mostly positive.
http://tinyurl.com/9obf
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2003-05-06 15:52
Message:
Logged In: YES
user_id=31435
I'm split. The current output when assertRaises fails is a
frequent cause of head-scratching ("what? it's complaining
because ValueError got raised? ... no, it's complaining
because ValueError wasn't raised? ..."). OTOH, I see no
value in trimming the traceback. Now that *could* be
because the assertRaises output can be so confusing that
we end up using the rest of the traceback to figure out what
unittest is trying to tell us in those cases.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-05-06 03:11
Message:
Logged In: YES
user_id=80475
I would like to see Thomas's patch or some comformant
variant go in. Usability problems are a bug. Friendlier
output makes it more likely that unittest will be used in
the first place.
----------------------------------------------------------------------
Comment By: Thomas Heller (theller)
Date: 2003-04-25 08:52
Message:
Logged In: YES
user_id=11105
Last attempt to convince you: I could try to port the
changes to Python 1.5, if you want to stay compatible.
If you still reject the patch (you're the unittest boss),
I'll have to live with subclassing unittest ;-)
----------------------------------------------------------------------
Comment By: Steve Purcell (purcell)
Date: 2003-04-25 08:37
Message:
Logged In: YES
user_id=21477
After investigation, this seems to work with Jython (though not JPython,
which didn't have tb_next etc.).
In general I've been trying hard to keep 'unittest.py' vanilla, since a lot
of people are still using it with Python 1.5 and even JPython. Hence the
complete absence of string methods, list comprehensions and other new
language features. Don't know if this policy makes sense in the longer
term, but I value it right now.
In that sense, I'm not sure if it's worth changing the message.
----------------------------------------------------------------------
Comment By: Thomas Heller (theller)
Date: 2003-04-25 08:05
Message:
Logged In: YES
user_id=11105
What a pity! What exactly does not work in Jython?
Before giving up on this, there are at least two ways to
proceed:
- Behave as before in Jython, and use the better output in
CPython.
- Apply this patch only the the unittest version bundled
with CPython.
How are the chances for one of this?
----------------------------------------------------------------------
Comment By: Steve Purcell (purcell)
Date: 2003-04-25 07:52
Message:
Logged In: YES
user_id=21477
This behaviour of trimming the traceback was implemented in a previous
version of PyUnit, but dropped because it did not work with Jython. My
aim is that the same 'unittest.py' should work out of the box with both
CPython and Jython.
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon)
Date: 2003-04-19 22:57
Message:
Logged In: YES
user_id=357491
I like the new output, personally. I am +1 on letting Thomas add the
changes.
Does this mean we no longer treat unittest as a separate project?
----------------------------------------------------------------------
Comment By: Thomas Heller (theller)
Date: 2003-04-17 11:31
Message:
Logged In: YES
user_id=11105
Attaching new version of the patch (unittest-2.diff). This
gives better output for failUnlessRaises, like this:
======================================================================
FAIL: test_failUnlessRaises (__main__.FailingTests)
----------------------------------------------------------------------
TestFailed: wrong exception, expected TypeError
got: 'ValueError: 10'
File "xunit.py", line 18, in test_failUnlessRaises
self.failUnlessRaises(TypeError, self._raise,
ValueError, 10)
======================================================================
FAIL: test_failUnlessRaises_2 (__main__.FailingTests)
----------------------------------------------------------------------
TestFailed: wrong exception, expected TypeError, IndexError,
or AttributeError
got: 'ValueError: 10'
File "xunit.py", line 21, in test_failUnlessRaises_2
self.failUnlessRaises((TypeError, IndexError,
AttributeError), self._raise, ValueError, 10)
----------------------------------------------------------------------
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=722638&group_id=5470