Table of Contents

Class: DocTestCase ./src/peak/util/_doctest.py
Base Classes   
unittest.TestCase
Methods   
__init__
__repr__
debug
format_failure
id
runTest
setUp
shortDescription
tearDown
  __init__ 
__init__ (
        self,
        test,
        optionflags=0,
        setUp=None,
        tearDown=None,
        checker=None,
        )

  __repr__ 
__repr__ ( self )

  debug 
debug ( self )

Run the test case without results and without catching exceptions

The unit test framework includes a debug method on test cases and test suites to support post-mortem debugging. The test code is run in such a way that errors are not caught. This way a caller can catch the errors and initiate post-mortem debugging.

The DocTestCase provides a debug method that raises UnexpectedException errors if there is an unexepcted exception:

>>> test = DocTestParser().get_doctest(>>> raise KeyError\n42, ... {}, foo, foo.py, 0) >>> case = DocTestCase(test) >>> try: ... case.debug() ... except UnexpectedException, failure: ... pass

The UnexpectedException contains the test, the example, and the original exception:

>>> failure.test is test True

>>> failure.example.want 42\n

>>> exc_info = failure.exc_info >>> raise exc_info[0], exc_info[1], exc_info[2] Traceback (most recent call last): ... KeyError

If the output doesn't match, then a DocTestFailure is raised:

>>> test = DocTestParser().get_doctest(''' ... >>> x = 1 ... >>> x ... 2 ... ''', {}, foo, foo.py, 0) >>> case = DocTestCase(test)

>>> try: ... case.debug() ... except DocTestFailure, failure: ... pass

DocTestFailure objects provide access to the test:

>>> failure.test is test True

As well as to the example:

             >>> failure.example.want
             '2\n'

and the actual output:

>>> failure.got 1\n

  format_failure 
format_failure ( self,  err )

  id 
id ( self )

  runTest 
runTest ( self )

Exceptions   
self.failureException(self.format_failure(new.getvalue() ) )
  setUp 
setUp ( self )

  shortDescription 
shortDescription ( self )

  tearDown 
tearDown ( self )


Table of Contents

This document was automatically generated on Mon Nov 11 01:11:04 2024 by HappyDoc version 2.1