On this page
  1. doctest.Example
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from doctest import Example
help(Example)

Linked from

Related notes