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

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

REPL Inspect

from doctest import run_docstring_examples
help(run_docstring_examples)

Linked from

Related notes