A current limitation of doctest is that it can't handle
output
containing blank lines, since it uses blank lines to
detect the end of
the example.
This patch adds a new option, END_WITH_DEDENT,
that gets around that
problem by using a dedent to detect the end of
examples instead. In
particular, when END_WITH_DEDENT is specified,
the end of each
indented doctest example is marked by a dedent
past its original
prompt (>>>). Thus, blank lines may appear within
the output.
However, trailing blank lines are still disallowed.
Unindented
docstring examples continue to be termined by a
blank line (since
dedenting past the prompt is impossible).
Here's an example use:
def f():
r"""
A doctest example with a blank line:
>>> print 'One\n\nTwo'
One
Two
Note that ending with dedents also means that we
can skip the
blank lines around doctest examples if we want:
>>> print 1
1
This dedent signifies the end of the example;
there's no need for
a blank line.
"""
The END_WITH_DEDENT uses the same optionflags
system that is already
used by DONT_ACCEPT_TRUE_FOR_1.
The patch was made avainst revision 1.33 of
doctest.py.
|