Back to index

python3.2  3.2.2
Public Member Functions | Static Private Attributes
doctest.DocFileCase Class Reference
Inheritance diagram for doctest.DocFileCase:
Inheritance graph
[legend]
Collaboration diagram for doctest.DocFileCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def id
def __repr__
def format_failure
def setUp
def tearDown
def runTest
def debug
def shortDescription

Static Private Attributes

 __str__ = __repr__

Detailed Description

Definition at line 2297 of file doctest.py.


Member Function Documentation

Reimplemented from doctest.DocTestCase.

Definition at line 2302 of file doctest.py.

02302 
02303     def __repr__(self):
        return self._dt_test.filename
def doctest.DocTestCase.debug (   self) [inherited]

Definition at line 2132 of file doctest.py.

02132 
02133     def debug(self):
02134         r"""Run the test case without results and without catching exceptions
02135 
02136            The unit test framework includes a debug method on test cases
02137            and test suites to support post-mortem debugging.  The test code
02138            is run in such a way that errors are not caught.  This way a
02139            caller can catch the errors and initiate post-mortem debugging.
02140 
02141            The DocTestCase provides a debug method that raises
02142            UnexpectedException errors if there is an unexpected
02143            exception:
02144 
02145              >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42',
02146              ...                {}, 'foo', 'foo.py', 0)
02147              >>> case = DocTestCase(test)
02148              >>> try:
02149              ...     case.debug()
02150              ... except UnexpectedException as f:
02151              ...     failure = f
02152 
02153            The UnexpectedException contains the test, the example, and
02154            the original exception:
02155 
02156              >>> failure.test is test
02157              True
02158 
02159              >>> failure.example.want
02160              '42\n'
02161 
02162              >>> exc_info = failure.exc_info
02163              >>> raise exc_info[1] # Already has the traceback
02164              Traceback (most recent call last):
02165              ...
02166              KeyError
02167 
02168            If the output doesn't match, then a DocTestFailure is raised:
02169 
02170              >>> test = DocTestParser().get_doctest('''
02171              ...      >>> x = 1
02172              ...      >>> x
02173              ...      2
02174              ...      ''', {}, 'foo', 'foo.py', 0)
02175              >>> case = DocTestCase(test)
02176 
02177              >>> try:
02178              ...    case.debug()
02179              ... except DocTestFailure as f:
02180              ...    failure = f
02181 
02182            DocTestFailure objects provide access to the test:
02183 
02184              >>> failure.test is test
02185              True
02186 
02187            As well as to the example:
02188 
02189              >>> failure.example.want
02190              '2\n'
02191 
02192            and the actual output:
02193 
02194              >>> failure.got
02195              '1\n'
02196 
02197            """
02198 
02199         self.setUp()
02200         runner = DebugRunner(optionflags=self._dt_optionflags,
02201                              checker=self._dt_checker, verbose=False)
02202         runner.run(self._dt_test, clear_globs=False)
02203         self.tearDown()

Here is the caller graph for this function:

def doctest.DocFileCase.format_failure (   self,
  err 
)

Reimplemented from doctest.DocTestCase.

Definition at line 2306 of file doctest.py.

02306 
02307     def format_failure(self, err):
02308         return ('Failed doctest test for %s\n  File "%s", line 0\n\n%s'
02309                 % (self._dt_test.name, self._dt_test.filename, err)
02310                 )

Here is the call graph for this function:

def doctest.DocFileCase.id (   self)

Reimplemented from doctest.DocTestCase.

Definition at line 2299 of file doctest.py.

02299 
02300     def id(self):
02301         return '_'.join(self._dt_test.name.split('.'))

Here is the caller graph for this function:

def doctest.DocTestCase.runTest (   self) [inherited]

Definition at line 2096 of file doctest.py.

02096 
02097     def runTest(self):
02098         test = self._dt_test
02099         old = sys.stdout
02100         new = StringIO()
02101         optionflags = self._dt_optionflags
02102 
02103         if not (optionflags & REPORTING_FLAGS):
02104             # The option flags don't include any reporting flags,
02105             # so add the default reporting flags
02106             optionflags |= _unittest_reportflags
02107 
02108         runner = DocTestRunner(optionflags=optionflags,
02109                                checker=self._dt_checker, verbose=False)
02110 
02111         try:
02112             runner.DIVIDER = "-"*70
02113             failures, tries = runner.run(
02114                 test, out=new.write, clear_globs=False)
02115         finally:
02116             sys.stdout = old
02117 
02118         if failures:
02119             raise self.failureException(self.format_failure(new.getvalue()))

Here is the call graph for this function:

def doctest.DocTestCase.setUp (   self) [inherited]

Reimplemented in doctest.SkipDocTestCase.

Definition at line 2082 of file doctest.py.

02082 
02083     def setUp(self):
02084         test = self._dt_test
02085 
02086         if self._dt_setUp is not None:
02087             self._dt_setUp(test)

Here is the caller graph for this function:

def doctest.DocTestCase.shortDescription (   self) [inherited]

Reimplemented in doctest.SkipDocTestCase.

Definition at line 2213 of file doctest.py.

02213 
02214     def shortDescription(self):
02215         return "Doctest: " + self._dt_test.name

Here is the caller graph for this function:

def doctest.DocTestCase.tearDown (   self) [inherited]

Definition at line 2088 of file doctest.py.

02088 
02089     def tearDown(self):
02090         test = self._dt_test
02091 
02092         if self._dt_tearDown is not None:
02093             self._dt_tearDown(test)
02094 
02095         test.globs.clear()

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from doctest.DocTestCase.

Definition at line 2304 of file doctest.py.


The documentation for this class was generated from the following file: