MCPcopy Index your code
hub / github.com/python/cpython / run_docstring_examples

Function run_docstring_examples

Lib/doctest.py:2242–2263  ·  view source on GitHub ↗

Test examples in the given object's docstring (`f`), using `globs` as globals. Optional argument `name` is used in failure messages. If the optional argument `verbose` is true, then generate output even if there are no failures. `compileflags` gives the set of flags that shoul

(f, globs, verbose=False, name="NoName",
                           compileflags=None, optionflags=0)

Source from the content-addressed store, hash-verified

2240
2241
2242def run_docstring_examples(f, globs, verbose=False, name="NoName",
2243 compileflags=None, optionflags=0):
2244 """
2245 Test examples in the given object's docstring (`f`), using `globs`
2246 as globals. Optional argument `name` is used in failure messages.
2247 If the optional argument `verbose` is true, then generate output
2248 even if there are no failures.
2249
2250 `compileflags` gives the set of flags that should be used by the
2251 Python compiler when running the examples. If not specified, then
2252 it will default to the set of future-import flags that apply to
2253 `globs`.
2254
2255 Optional keyword arg `optionflags` specifies options for the
2256 testing and output. See the documentation for `testmod` for more
2257 information.
2258 """
2259 # Find, parse, and run all tests in the given module.
2260 finder = DocTestFinder(verbose=verbose, recurse=False)
2261 runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
2262 for test in finder.find(f, name, globs=globs):
2263 runner.run(test, compileflags=compileflags)
2264
2265######################################################################
2266## 7. Unittest Support

Callers

nothing calls this directly

Calls 4

findMethod · 0.95
runMethod · 0.95
DocTestFinderClass · 0.85
DocTestRunnerClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…