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

Function testsource

Lib/doctest.py:2801–2815  ·  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

2799 return '\n'.join(output) + '\n'
2800
2801def testsource(module, name):
2802 """Extract the test sources from a doctest docstring as a script.
2803
2804 Provide the module (or dotted name of the module) containing the
2805 test to be debugged and the name (within the module) of the object
2806 with the doc string with tests to be debugged.
2807 """
2808 module = _normalize_module(module)
2809 tests = DocTestFinder().find(module)
2810 test = [t for t in tests if t.name == name]
2811 if not test:
2812 raise ValueError(name, "not found in tests")
2813 test = test[0]
2814 testsrc = script_from_examples(test.docstring)
2815 return testsrc
2816
2817def debug_src(src, pm=False, globs=None):
2818 """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

Used in the wild real call sites across dependent graphs

searching dependent graphs…