doctest.py
doctest.REAMDE
to python.org's FTP incoming directory. If ftpmaster is awake <wink>, I
expect they'll show up within a few days, under
http://www.python.org/ftp/python/contrib/System/
In the meantime, I'll attach the README and the change log.
really-glad-it-serves-as-its-own-test<wink>-ly y'rs - tim
doctest.README:
# Module doctest version 0.9.1
# Released to the public domain 08-Mar-1999,
# by Tim Peters (tim...@email.msn.com).
doctest.py provides a flexible framework for automatically testing
examples in docstrings. It's very easy to use (well, at least to
use as intended ...):
+ Run some illuminating examples in an interactive session.
+ Paste a copy of that session into a docstring, interspered freely
among your docstring prose.
+ Add a few lines of boilerplate code to the end of the module, to
invoke the doctest magic when your module is run directly as a
script: the docstring examples will be found and interpreted,
verifying they still work exactly as advertised.
Extensive docs are in doctest.py's docstrings, and some even serve
as non-trivial examples of doctest's intended use. Warning: thinking
too hard about how doctest manages to run docstring examples of its
own use in its own source code can make your head explode <kaboom>.
Change log:
# 0,0,1 06-Mar-1999
# initial version posted
# 0,0,2 06-Mar-1999
# loosened parsing:
# cater to stinkin' tabs
# don't insist on a blank after PS2 prefix
# so trailing "... " line from a compound stmt no longer
# breaks if the file gets whitespace-trimmed
# better error msgs for inconsistent leading whitespace
# 0,9,1 08-Mar-1999
# exposed the Tester class and added client methods
# plus docstring examples of their use (eww - head-twisting!)
# fixed logic error in reporting total # of tests & failures
# added __test__ support to testmod (a pale reflection of Christian
# Tismer's vision ...)
# removed the "deep" argument; fiddle __test__ instead
# simplified endcase logic for extracting tests, and running them
# before, if no output was expected but some was produced
# anyway via an eval'ed result, the discrepancy wasn't caught
# made TestClass private and used __test__ to get at it
# many doc updates
# speed _SpoofOut for long expected outputs