all Python 3doctestfunction
doctest.debug_src()
debugging
Runs the examples from a string under the pdb debugger so you can step through the code and inspect variables.
Syntax
doctest.debug_src(src, pm=False, globs=None)
The expected output is not checked — this is debugging, not testing. The whole script runs as a single exec(), so next jumps over all of it; use step to get inside. pm=True replaces stepping with a post-mortem session opened only after an exception.
Examples
import doctest, io, sys
sys.stdin = io.StringIO("next\np x * 10\ncontinue\n") # команды pdb вместо клавиатуры
doctest.debug_src(">>> x = 2\n>>> x * 3\n6\n")
print("done") # → done — а выше pdb напечатал 20
See also
Open in the full glossarydocs.python.orgReport an inaccuracy