On this page
doctest.Example
Prev: doctest.DocTestSuite | Up: doctest | Next: doctest.OutputChecker
Rel: doctest.debug, doctest.debug_src, doctest.DebugRunner, doctest.DocFileSuite
Ref: docs.python.org — doctest.Example
Tags: #public #python3 #stdlib #doctest
Import
import doctest
from doctest import Example
Signature & Overview
doctest.Example(source, want, exc_msg=None, lineno=0, indent=0, options=None)
A single doctest example, consisting of source code and expected output. Example defines the following attributes: - source: A single Python statement, always ending with a newline.
Usage
import doctest
ex = doctest.Example("1 + 1\n", "2\n")
assert ex.source == "1 + 1\n" and ex.want == "2\n"
Gotchas
- Represents one
>>>input and its expected output.
REPL Inspect
from doctest import Example
help(Example)
Linked from
Related notes
- tuts/python3/stdlib_module/doctest/DocTestSuite Linked here; links to this page; shared tags: #doctest, #stdlib
- tuts/python3/stdlib_module/doctest/OutputChecker 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