[checker][, verbose][, optionflags]) |
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 section 5.2.3 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 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.
The optional keyword argument checker specifies the OutputChecker object (or drop-in replacement) that should be used to compare the expected outputs to the actual outputs of doctest examples.
The optional keyword argument verbose controls the
DocTestRunner's verbosity. If verbose is
True
, then information is printed about each example, as it
is run. If verbose is False
, then only failures are
printed. If verbose is unspecified, or None
, then
verbose output is used iff the command-line switch -v
is used.
The optional keyword argument optionflags can be used to control how the test runner compares expected output to actual output, and how it displays failures. For more information, see section 5.2.3.
New in version 2.4.
DocTestParser defines the following methods:
out, test, example) |
example is the example about to be processed. test is the test containing example. out is the output function that was passed to DocTestRunner.run().
out, test, example, got) |
example is the example about to be processed. got is the actual output from the example. test is the test containing example. out is the output function that was passed to DocTestRunner.run().
out, test, example, got) |
example is the example about to be processed. got is the actual output from the example. test is the test containing example. out is the output function that was passed to DocTestRunner.run().
out, test, example, exc_info) |
example is the example about to be processed. exc_info is a tuple containing information about the unexpected exception (as returned by sys.exc_info()). test is the test containing example. out is the output function that was passed to DocTestRunner.run().
test[, compileflags][, out][, clear_globs]) |
The examples are run in the namespace test.globs
. If
clear_globs is true (the default), then this namespace will
be cleared after the test runs, to help with garbage collection.
If you would like to examine the namespace after the test
completes, then use clear_globs=False.
compileflags gives the set of flags that should be used by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to globs.
The output of each example is checked using the DocTestRunner's output checker, and the results are formatted by the DocTestRunner.report_* methods.
[verbose]) |
The optional verbose argument controls how detailed the summary is. If the verbosity is not specified, then the DocTestRunner's verbosity is used.
See About this document... for information on suggesting changes.