On this page
doctest.OutputChecker
Prev: doctest.Example | Up: doctest | Next: doctest.register_optionflag
Rel: doctest.debug, doctest.debug_src, doctest.DebugRunner, doctest.DocFileSuite
Ref: docs.python.org โ doctest.OutputChecker
Tags: #public #python3 #stdlib #doctest
Import
import doctest
from doctest import OutputChecker
Signature & Overview
doctest.OutputChecker()
A class used to check whether the actual output from a doctest example matches the expected output. OutputChecker defines two methods: check_output, which compares a given pair of outputs,
Methods & Attributes
OutputChecker.check_output(self, want, got, optionflags)โ Return True iff the actual output from an example (got) matches the expected output (want). These strings are always considered to match if they are identical; butOutputChecker.output_difference(self, example, got, optionflags)โ Return a string describing the differences between the expected output for a given example (example) and the actual output (got).optionflagsis the set of option flags used
Usage
import doctest
checker = doctest.OutputChecker()
assert checker.check_output("hello ...\n", "hello world\n", doctest.ELLIPSIS) is True
Gotchas
- Subclass
OutputCheckerto customize float tolerance or ignore nondeterministic output.
REPL Inspect
from doctest import OutputChecker
help(OutputChecker)
Linked from
Related notes
- tuts/python3/stdlib_module/doctest/Example Linked here; links to this page; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/register_optionflag Linked here; links to this page; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/debug Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/debug_src Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DebugRunner Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocFileSuite Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocTest Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/doctest/DocTestFailure shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocTestFinder shared tags: #doctest, #stdlib