reStructuredText format. Remove words describing the return value of
testmod() and testfile() in the intro sections, since it's never
useful in such simple cases.
- Reorganized the documentation
- Shifted focus a little more towards "literate testing"
- Documented new functions and classes:
- testfile()
- Example, DocTest
- DocTestParser, DocTestFinder, DocTestRunner, OutputChecker
- DocFileSuite
- DebugRunner, DocTestFailure, UnexpectedException
- register_optionflag()
- Minor wording changes
- Changed the docs to reflect the fact that multiple option directives
can be specified on a single line (and updated the directive
production list, as well).
in the new docs.
DocTestRunner.__run: Separate the determination of the example outcome
from reporting that outcome, to squash brittle code duplication and
excessive nesting.
to unittest, so make it official: new module constants COMPARISON_FLAGS
and REPORTING_FLAGS, which are bitmasks or'ing together the relevant
individual option flags.
set_unittest_reportflags(): Reworked to use REPORTING_FLAGS, and
simplified overly complicated flag logic.
class FakeModule: Removed this; neither documented nor used.
NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that
all reporting options should begin with "REPORT_" (since reporting
options are a different class from output comparison options; but they
are both set in optionflags).
a traceback message. I.e., examples that raise exceptions may no
longer generate pre-exception output. This restores the behavior of
doctest in python 2.3. The ability to check pre-exception output is
being removed because it makes the documentation simpler; and because
there are very few use cases for it.
in this section is new in 2.4, and that's all mentioned already in
versionadded{} thingies at the end of the section. It hurts readability
to have them after every line <wink>.
them (which they are now), I had to rewrite the code to understand
it. This has got to be the most DWIM part of doctest -- but in context
is really necessary.
skip over functions with private names (as indicated by the underscore
naming convention). The old default created too much of a risk that
user tests were being skipped inadvertently. Note, this change could
break code in the unlikely case that someone had intentionally put
failing tests in the docstrings of private functions. The breakage
is easily fixable by specifying the old behavior when calling testmod()
or Tester(). The more likely case is that the silent failure was
unintended and that the user needed to be informed so the test could be
fixed.
now accepts "True" when a test expects "1", and similarly for "False"
versus "0". This is un-doctest-like, but on balance makes it much
more pleasant to write doctests that pass under 2.2 and 2.3. I expect
it to go away again, when 2.2 is forgotten. In the meantime, there's
a new doctest module constant that can be passed to a new optional
argument, if you want to turn this behavior off.
Note that this substitution is very simple-minded: the expected and
actual outputs have to consist of single tokens. No attempt is made,
e.g., to accept [True, False] when a test expects [1, 0]. This is a
simple hack for simple tests, and I intend to keep it that way.