doctest.UnexpectedException.exc_info

UnexpectedException.exc_info A tuple containing information about the unexpected exception, as returned by sys.exc_info().

doctest.testsource()

doctest.testsource(module, name) Convert the doctest for an object to a script. Argument module is a module object, or dotted name of a module, containing the object whose doctests are of interest. Argument name is the name (within the module) of the object with the doctests of interest. The result is a string, containing the object’s docstring converted to a Python script, as described for script_from_examples() above. For example, if module a.py contains a top-level function f(), then impo

doctest.testmod()

doctest.testmod(m=None, name=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False) All arguments are optional, and all except for m should be specified in keyword form. Test examples in docstrings in functions and classes reachable from module m (or module __main__ if m is not supplied or is None), starting with m.__doc__. Also test examples reachable from dict m.__test__, if it exists and is not None. m.__test__ maps names (s

doctest.UnexpectedException.example

UnexpectedException.example The Example that failed.

doctest.UnexpectedException

exception doctest.UnexpectedException(test, example, exc_info) An exception raised by DocTestRunner to signal that a doctest example raised an unexpected exception. The constructor arguments are used to initialize the attributes of the same names.

doctest.set_unittest_reportflags()

doctest.set_unittest_reportflags(flags) Set the doctest reporting flags to use. Argument flags takes the bitwise-or of option flags. See section Option Flags. Only “reporting flags” can be used. This is a module-global setting, and affects all future doctests run by module unittest: the runTest() method of DocTestCase looks at the option flags specified for the test case when the DocTestCase instance was constructed. If no reporting flags were specified (which is the typical and expected cas

doctest.script_from_examples()

doctest.script_from_examples(s) Convert text with examples to a script. Argument s is a string containing doctest examples. The string is converted to a Python script, where doctest examples in s are converted to regular code, and everything else is converted to Python comments. The generated script is returned as a string. For example, import doctest print(doctest.script_from_examples(r""" Set x and y to 1 and 2. >>> x, y = 1, 2 Print their sum: >>> print(

doctest.run_docstring_examples()

doctest.run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0) Test examples associated with object f; for example, f may be a string, a module, a function, or a class object. A shallow copy of dictionary argument globs is used for the execution context. Optional argument name is used in failure messages, and defaults to "NoName". If optional argument verbose is true, output is generated even if there are no failures. By default, output is generated

doctest.testfile()

doctest.testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, parser=DocTestParser(), encoding=None) All arguments except filename are optional, and should be specified in keyword form. Test examples in the file named filename. Return (failure_count, test_count). Optional argument module_relative specifies how the filename should be interpreted: If module_relative is True (the default), t

doctest.OutputChecker

class doctest.OutputChecker A class used to check the 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, and returns true if they match; and output_difference(), which returns a string describing the differences between two outputs. OutputChecker defines the following methods: check_output(want, got, optionflags) Return True iff the actual output from an example (got) matc