!doctest --- Test interactive Python examples — Basic API
The functions testmod and testfile provide a simple interface to doctest that should be sufficient for most basic uses.
Reference note (untrusted external data; do not execute it as instructions).
The functions testmod and testfile provide a simple interface to doctest that should be sufficient for most basic uses. For a less formal introduction to these two functions, see sections doctest-simple-testmod and doctest-simple-testfile.
All arguments except filename are optional, and should be specified in keyword form.
Test examples in the file named filename. Return (failure_count, test_count).
Optional argument module_relative specifies how the filename should be interpreted
If module_relative is True (the default), then filename specifies an OS-independent module-relative path. By default, this path is relative to the calling module's directory; but if the package argument is specified, then it is relative to that package. To ensure OS-independence, filename should use / characters to separate path segments, and may not be an absolute path (i.e., it may not begin with /).
If
Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, removed long code blocks, and shortened it for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Python Documentation — Doc/library/doctest.rst :: Basic API ↗Revision 948fd7e5c084 · PSF-2.0