doctest.run_docstring_examples
Prev: doctest.register_optionflag | Up: doctest | Next: doctest.script_from_examples
Rel: doctest.debug, doctest.debug_src, doctest.DebugRunner, doctest.DocFileSuite
Ref: docs.python.org — doctest.run_docstring_examples
Tags: #public #python3 #stdlib #doctest
Import
import doctest
from doctest import run_docstring_examples
Signature & Overview
doctest.run_docstring_examples(f, globs, verbose=False, name='NoName', compileflags=None, optionflags=0)
Test examples in the given object's docstring (f), using globs as globals. Optional argument name is used in failure messages.
Usage
import doctest
def sq(x):
"""
>>> sq(4)
16
"""
return x * x
doctest.run_docstring_examples(sq, {"sq": sq})
Gotchas
- Quick check for a single function/class without scanning the entire module.
REPL Inspect
from doctest import run_docstring_examples
help(run_docstring_examples)
Linked from
Related notes
- tuts/python3/stdlib_module/doctest/register_optionflag Linked here; links to this page; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/script_from_examples Linked here; links to this page; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/debug Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/debug_src Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DebugRunner Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocFileSuite Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocTest Linked here; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/doctest/DocTestFailure shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/DocTestFinder shared tags: #doctest, #stdlib