Doctest Integration

The doctest module, on the doctest module:

The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. There are several common ways to use doctest:

  • To check that a module's docstrings are up-to-date by verifying that all interactive examples still work as documented.

  • To perform regression testing by verifying that interactive examples from a test file or a test object work as expected.

  • To write tutorial documentation for a package, liberally illustrated with input-output examples. Depending on whether the examples or the expository text are emphasized, this has the flavor of "literate testing" or "executable documentation".

Because of the way that doctest gathers tests to run, it is not possible to run tests collected from typechecked functions "out-of-the-box". In order to enable support for this feature you need to add the following code to your project:

import typecheck.doctest_support

This line of code must appear in your project before any accesses to members of the doctest module.

Valid XHTML 1.0 Transitional