Logo Search packages:      
Sourcecode: distribute version File versions  Download package

setuptools::tests::doctest::DocTestRunner Class Reference

Inherited by setuptools::tests::doctest::DebugRunner.

List of all members.


Detailed Description

5.

DocTest Runner

A class used to run DocTest test cases, and accumulate statistics.
The `run` method is used to process a single DocTest case.  It
returns a tuple `(f, t)`, where `t` is the number of test cases
tried, and `f` is the number of test cases that failed.

    >>> tests = DocTestFinder().find(_TestClass)
    >>> runner = DocTestRunner(verbose=False)
    >>> for test in tests:
    ...     print runner.run(test)
    (0, 2)
    (0, 1)
    (0, 2)
    (0, 2)

The `summarize` method prints a summary of all the test cases that
have been run by the runner, and returns an aggregated `(f, t)`
tuple:

    >>> runner.summarize(verbose=1)
    4 items passed all tests:
       2 tests in _TestClass
       2 tests in _TestClass.__init__
       2 tests in _TestClass.get
       1 tests in _TestClass.square
    7 tests in 4 items.
    7 passed and 0 failed.
    Test passed.
    (0, 7)

The aggregated number of tried examples and failed examples is
also available via the `tries` and `failures` attributes:

    >>> runner.tries
    7
    >>> runner.failures
    0

The comparison between expected outputs and actual outputs is done
by an `OutputChecker`.  This comparison may be customized with a
number of option flags; see the documentation for `testmod` for
more information.  If the option flags are insufficient, then the
comparison may also be customized by passing a subclass of
`OutputChecker` to the constructor.

The test runner's display output can be controlled in two ways.
First, an output function (`out) can be passed to
`TestRunner.run`; this function will be called with strings that
should be displayed.  It defaults to `sys.stdout.write`.  If
capturing the output is not sufficient, then the display output
can be also customized by subclassing DocTestRunner, and
overriding the methods `report_start`, `report_success`,
`report_unexpected_exception`, and `report_failure`.

Definition at line 1050 of file doctest.py.


Public Member Functions

def __init__
def merge
def report_failure
def report_start
def report_success
def report_unexpected_exception
def run
def summarize

Public Attributes

 debugger
 failures
 optionflags
 original_optionflags
 save_linecache_getlines
 test
 tries

Static Public Attributes

string DIVIDER = "*"

Private Member Functions

def __patched_linecache_getlines
def __record_outcome
def __run
def _failure_header

Private Attributes

 _checker
 _fakeout
 _name2ft
 _verbose

Static Private Attributes

tuple __LINECACHE_FILENAME_RE

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

Generated by  Doxygen 1.6.0   Back to index