doctest.UnexpectedException.exc_info

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

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.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.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.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.register_optionflag()

doctest.register_optionflag(name) Create a new option flag with a given name, and return the new flag’s integer value. register_optionflag() can be used when subclassing OutputChecker or DocTestRunner to create new options that are supported by your subclasses. register_optionflag() should always be called using the following idiom: MY_FLAG = register_optionflag('MY_FLAG')