MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / run_docstring_examples

Function run_docstring_examples

tools/python-3.11.9-amd64/Lib/doctest.py:2127–2148  ·  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

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

Source from the content-addressed store, hash-verified

2125 return TestResults(runner.failures, runner.tries)
2126
2127def run_docstring_examples(f, globs, verbose=False, name="NoName",
2128 compileflags=None, optionflags=0):
2129 """
2130 Test examples in the given object's docstring (`f`), using `globs`
2131 as globals. Optional argument `name` is used in failure messages.
2132 If the optional argument `verbose` is true, then generate output
2133 even if there are no failures.
2134
2135 `compileflags` gives the set of flags that should be used by the
2136 Python compiler when running the examples. If not specified, then
2137 it will default to the set of future-import flags that apply to
2138 `globs`.
2139
2140 Optional keyword arg `optionflags` specifies options for the
2141 testing and output. See the documentation for `testmod` for more
2142 information.
2143 """
2144 # Find, parse, and run all tests in the given module.
2145 finder = DocTestFinder(verbose=verbose, recurse=False)
2146 runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
2147 for test in finder.find(f, name, globs=globs):
2148 runner.run(test, compileflags=compileflags)
2149
2150######################################################################
2151## 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