[Python-checkins] python/dist/src/Doc/lib libunittest.tex, 1.14.8.2, 1.14.8.3

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Dec 7 05:49:16 EST 2003


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv12697
Modified Files:
 Tag: release23-maint
	libunittest.tex 
Log Message:
SF bug #855317: unittest: 5.3.9 Getting Extended Error Information 
The example code did not work and could not easily be made to work.
Since the docs were already complex and the feature was not used
(it took two years for the errors to surface), we decided to dedocument
it entirely, leaving unittest cleaner than before.
Index: libunittest.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunittest.tex,v
retrieving revision 1.14.8.2
retrieving revision 1.14.8.3
diff -C2 -d -r1.14.8.2 -r1.14.8.3
*** libunittest.tex	20 Sep 2003 11:09:06 -0000	1.14.8.2
--- libunittest.tex	7 Dec 2003 10:49:13 -0000	1.14.8.3
***************
*** 901,944 ****
 the \class{TestSuite} class.
 \end{memberdesc}
- 
- 
- \subsection{Getting Extended Error Information
- \label{unittest-error-info}}
- 
- Some applications can make use of more error information (for example,
- an integrated development environment, or IDE). Such an application
- can retrieve supplemental information about errors and failures by
- using an alternate \class{TestResult} implementation, and extending
- the \method{defaultTestResult()} method of the \class{TestCase} class
- to provide it.
- 
- Here is a brief example of a \class{TestResult} subclass which stores
- the actual exception and traceback objects. (Be aware that storing
- traceback objects can cause a great deal of memory not to be reclaimed
- when it otherwise would be, which can have effects that affect the
- behavior of the tests.)
- 
- \begin{verbatim}
- import unittest
- 
- class MyTestCase(unittest.TestCase):
- def defaultTestResult(self):
- return MyTestResult()
- 
- class MyTestResult(unittest.TestResult):
- def __init__(self):
- self.errors_tb = []
- self.failures_tb = []
- 
- def addError(self, test, err):
- self.errors_tb.append((test, err))
- unittest.TestResult.addError(self, test, err)
- 
- def addFailure(self, test, err):
- self.failures_tb.append((test, err))
- unittest.TestResult.addFailure(self, test, err)
- \end{verbatim}
- 
- Tests written using \class{MyTestCase} as the base class, instead of
- \class{TestCase}, will allow tools to extract additional information
- from the results object.
--- 901,902 ----


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /