[Patches] [ python-Patches-932933 ] doctest: add an option to end
examples w/ dedent
SourceForge.net
noreply at sourceforge.net
Sat Apr 10 16:00:02 EDT 2004
Patches item #932933, was opened at 2004-04-10 15:56
Message generated for change (Comment added) made by edloper
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=932933&group_id=5470
Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Edward Loper (edloper)
Assigned to: Nobody/Anonymous (nobody)
Summary: doctest: add an option to end examples w/ dedent
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Edward Loper (edloper)
Date: 2004-04-10 16:00
Message:
Logged In: YES
user_id=195958
If this patch looks good, I'd be happy to write a patch for
the docs & test cases.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=932933&group_id=5470
More information about the Patches
mailing list