doctest.DocTestSuite()

doctest.DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, checker=None) Convert doctest tests for a module to a unittest.TestSuite. The returned unittest.TestSuite is to be run by the unittest framework and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and a failureException exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. Opti

doctest.DocTestRunner.summarize()

summarize(verbose=None) Print a summary of all the test cases that have been run by this DocTestRunner, and return a named tuple TestResults(failed, attempted). The optional verbose argument controls how detailed the summary is. If the verbosity is not specified, then the DocTestRunner‘s verbosity is used.

doctest.DocTestRunner.run()

run(test, compileflags=None, out=None, clear_globs=True) Run the examples in test (a DocTest object), and display the results using the writer function out. 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 P

doctest.DocTestRunner.report_unexpected_exception()

report_unexpected_exception(out, test, example, exc_info) Report that the given example raised an unexpected exception. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. 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(

doctest.DocTestRunner.report_success()

report_success(out, test, example, got) Report that the given example ran successfully. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. 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().

doctest.DocTestRunner.report_start()

report_start(out, test, example) Report that the test runner is about to process the given example. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. 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().

doctest.DocTestRunner.report_failure()

report_failure(out, test, example, got) Report that the given example failed. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. 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().

doctest.DocTestRunner

class doctest.DocTestRunner(checker=None, verbose=None, optionflags=0) A processing class used to execute and verify the interactive examples in a DocTest. 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 Option Flags 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.

doctest.DocTestParser.parse()

parse(string, name='') Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings. Line numbers for the Examples are 0-based. The optional argument name is a name identifying this string, and is only used for error messages.

doctest.DocTestParser.get_examples()

get_examples(string, name='') Extract all doctest examples from the given string, and return them as a list of Example objects. Line numbers are 0-based. The optional argument name is a name identifying this string, and is only used for error messages.