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.

classification
Title: unittest.TestResult documentation
Type: Stage:
Components: Documentation Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, sbidoul
Priority: normal Keywords:

Created on 2002-05-20 13:51 by sbidoul, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (2)
msg10880 - (view) Author: Stéphane Bidoul (sbidoul) * Date: 2002-05-20 13:51
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
msg10881 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-07-02 22:35
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.
History
Date User Action Args
2022-04-10 16:05:20adminsetgithub: 36624
2002-05-20 13:51:28sbidoulcreate