[Python-bugs-list] [ python-Bugs-558278 ] unittest.TestResult documentation
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 02 Jul 2002 15:35:56 -0700
Bugs item #558278, was opened at 2002-05-20 09:51
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=558278&group_id=5470
Category: Documentation
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Stéphane Bidoul (sbidoul)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: unittest.TestResult documentation
Initial Comment:
The documentation of unittest.TestResult states:
<snip>
TestResult instances have the following attributes
that will be of interest when inspecting the
results of running a set of tests:
errors
A list containing pairs of TestCase instances and
the sys.exc_info() results for tests which raised
an exception but did not signal a test failure.
failures
A list containing pairs of TestCase instances and
the sys.exc_info() results for tests which
signalled a failure in the code under test.
</snip>
unittest.py (version 1.14) has, in the docstring of
TestResult:
<snip>
Each instance holds the total number of tests run, and
collections of failures and errors that occurred among
those test runs. The collections contain tuples of
(testcase, exceptioninfo), where exceptioninfo is the
*formatted* traceback of the error that occurred.
</snip>
So the second parts of the errors and failures lists
of pairs are actually strings and not sys.exc_info()
tuples. The docstring in the code looks correct to me,
so I guess the documentation needs to be fixed. Note
that this behaviour changed between python 2.1 and
python 2.2.
As a side note, I noticed the problem because I had a
custom test runner that exploited the traceback
information to customize the display of results based
on the actual failureException subclass. I overcame
that by maintaining my own errors and failure lists in
a subclass of TestResult.
Now, I've read the rationale for keeping only
formatted tracebacks, but this kind of use of the
traceback for customized result display looked useful
to me. May be there is a better way?
Regards.
-Stephane
----------------------------------------------------------------------
>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-07-02 18:35
Message:
Logged In: YES
user_id=3066
Fixed the documentation in Doc/lib/libunittest.tex
(revisions 1.8 and 1.7.8.1), and added a brief example of
how to create an extended TestResult object.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=558278&group_id=5470