{"slug":"ref-python-343436fae63d2ff6c0d1","title":"doctest --- Test interactive Python examples — DocTestRunner objects","summary":"A processing class used to execute and verify the interactive examples in a DocTest.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nA processing class used to execute and verify the interactive examples in a DocTest.\n\nThe 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 doctest-options 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.\n\nThe test runner's display output can be controlled in two ways. First, an output function can be passed to 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_skip, report_start, report_success, report_unexpected_exception, and report_failure.\n\nThe 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.\n\nThe 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.\n\nThe 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 doctest-options.\n\nThe test runner accumulates statistics. The aggregated number of attempted, failed and skipped examples is also available via the tries, failures and skips attributes. The run and summarize methods return a TestResults instance.\n\nDocTestRunner defines the following methods\n\nDocTestParser has the following attributes\n\nAttribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","python","library","doctest","test","interactive","examples","doctestrunner","objects"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/python/cpython/blob/f10166035d602da5052e8a48f9d5c216c57b401d/Doc/library/doctest.rst","source_name":"Python Documentation","source_license":"PSF-2.0","source_revision":"f10166035d602da5052e8a48f9d5c216c57b401d","source_path":"Doc/library/doctest.rst :: DocTestRunner objects","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.533224+00:00","url":"https://wikikv.com/k/ref-python-343436fae63d2ff6c0d1","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-python-343436fae63d2ff6c0d1","markdown":"https://wikikv.com/k/ref-python-343436fae63d2ff6c0d1?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-python-343436fae63d2ff6c0d1","json_ld":"https://wikikv.com/k/ref-python-343436fae63d2ff6c0d1?format=jsonld"}}