m, name=None, globs=None, verbose=None, isprivate=None, report=1
Test examples in docstrings in functions and classes reachable from
module m, starting with m.__doc__. Private names are skipped.
Also test examples reachable from dict m.__test__ if it exists and is
not None. m.__dict__ maps names to functions, classes and strings;
function and class docstrings are tested even if the name is private;
strings are tested directly, as if they were docstrings.
Return (#failures, #tests).
See doctest.__doc__ for an overview.
Optional keyword arg "name" gives the name of the module; by default
use m.__name__.
Optional keyword arg "globs" gives a dict to be used as the globals
when executing examples; by default, use m.__dict__. A copy of this
dict is actually used for each docstring, so that each docstring's
examples start with a clean slate.
Optional keyword arg "verbose" prints lots of stuff if true, prints
only failures if false; by default, it's true iff "-v" is in sys.argv.
Optional keyword arg "isprivate" specifies a function used to
determine whether a name is private. The default function is
doctest.is_private; see its docs for details.
Optional keyword arg "report" prints a summary at the end when true,
else prints nothing at the end. In verbose mode, the summary is
detailed, else very brief (in fact, empty if all tests passed).
Advanced tomfoolery: testmod runs methods of a local instance of
class doctest.Tester, then merges the results into (or creates)
global Tester instance doctest.master. Methods of doctest.master
can be called directly too, if you want to do something unusual.
Passing report=0 to testmod is especially useful then, to delay
displaying a summary. Invoke doctest.master.summarize(verbose)
when you're done fiddling.
Definition at line 1044 of file doctest.py.
1046 """m, name=None, globs=None, verbose=None, isprivate=None, report=1
1048 Test examples in docstrings in functions and classes reachable from
1049 module m, starting with m.__doc__. Private names are skipped.
1051 Also test examples reachable from dict m.__test__ if it exists and is
1052 not None. m.__dict__ maps names to functions, classes and strings;
1053 function and class docstrings are tested even if the name is private;
1054 strings are tested directly, as if they were docstrings.
1056 Return (#failures, #tests).
1058 See doctest.__doc__ for an overview.
1060 Optional keyword arg "name" gives the name of the module; by default
1063 Optional keyword arg "globs" gives a dict to be used as the globals
1064 when executing examples; by default, use m.__dict__. A copy of this
1065 dict is actually used for each docstring, so that each docstring's
1066 examples start with a clean slate.
1068 Optional keyword arg "verbose" prints lots of stuff if true, prints
1069 only failures if false; by default, it's true iff "-v" is in sys.argv.
1071 Optional keyword arg "isprivate" specifies a function used to
1072 determine whether a name is private. The default function is
1073 doctest.is_private; see its docs for details.
1075 Optional keyword arg "report" prints a summary at the end when true,
1076 else prints nothing at the end. In verbose mode, the summary is
1077 detailed, else very brief (in fact, empty if all tests passed).
1079 Advanced tomfoolery: testmod runs methods of a local instance of
1080 class doctest.Tester, then merges the results into (or creates)
1081 global Tester instance doctest.master. Methods of doctest.master
1082 can be called directly too, if you want to do something unusual.
1083 Passing report=0 to testmod is especially useful then, to delay
1084 displaying a summary. Invoke doctest.master.summarize(verbose)
1085 when you're done fiddling.
1090 if not _ismodule(m):
1091 raise TypeError(
"testmod: module required; " + `m`)
1094 tester =
Tester(m, globs=globs, verbose=verbose, isprivate=isprivate)
1095 failures, tries = tester.rundoc(m, name)
1096 f, t = tester.rundict(m.__dict__, name, m)
1097 failures = failures + f
1099 if hasattr(m,
"__test__"):
1100 testdict = m.__test__
1102 if not hasattr(testdict,
"items"):
1103 raise TypeError(
"testmod: module.__test__ must support "
1104 ".items(); " + `testdict`)
1105 f, t = tester.run__test__(testdict, name +
".__test__")
1106 failures = failures + f
1113 master.merge(tester)
1114 return failures, tries