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

Function testsource

tools/python-3.11.9-amd64/Lib/doctest.py:2636–2650  ·  view source on GitHub ↗

Extract the test sources from a doctest docstring as a script. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged.

(module, name)

Source from the content-addressed store, hash-verified

2634 return '\n'.join(output) + '\n'
2635
2636def testsource(module, name):
2637 """Extract the test sources from a doctest docstring as a script.
2638
2639 Provide the module (or dotted name of the module) containing the
2640 test to be debugged and the name (within the module) of the object
2641 with the doc string with tests to be debugged.
2642 """
2643 module = _normalize_module(module)
2644 tests = DocTestFinder().find(module)
2645 test = [t for t in tests if t.name == name]
2646 if not test:
2647 raise ValueError(name, "not found in tests")
2648 test = test[0]
2649 testsrc = script_from_examples(test.docstring)
2650 return testsrc
2651
2652def debug_src(src, pm=False, globs=None):
2653 """Debug a single doctest docstring, in argument `src`'"""

Callers 1

debugFunction · 0.85

Calls 4

_normalize_moduleFunction · 0.85
DocTestFinderClass · 0.85
script_from_examplesFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected