[Patches] [ python-Patches-722638 ] Better output for unittest

SourceForge.net noreply@sourceforge.net
Fri, 25 Apr 2003 04:52:46 -0700


Patches item #722638, was opened at 2003-04-16 19:49
Message generated for change (Comment added) made by purcell
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: Steve Purcell (purcell)
Date: 2003-04-25 13: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-20 04: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 17: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