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

import a, doctest
print(doctest.testsource(a, "a.f"))

prints a script version of function f()‘s docstring, with doctests converted to code, and the rest placed in comments.

doc_python
2016-10-07 17:32:15
Comments
Leave a Comment

Please login to continue.