[Patches] [ python-Patches-407764 ] allow whitespace lines for doctest tests
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 18 Oct 2001 18:01:11 -0700
Patches item #407764, was opened at 2001-03-11 13:37
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=407764&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Trent Mick (tmick)
Assigned to: Trent Mick (tmick)
Summary: allow whitespace lines for doctest tests
Initial Comment:
Currently doctest.py does not allow individual tests
to have all-whitespace output lines. This patch
proposes a fix for this. With this patch a leading '.'
on a doctest output line, if and only if the tests are
indented, will signal that following whitespace *is*
the expected output.
For example, currently this cannot be doctest'ed
"""
>>> print "\nhello\n"
hello
>>>
"""
But with this patch *this* can be:
# file test_doctest.py
"""
>>> print "\nhello\n"
.
hello
.
>>>
"""
def _test():
import doctest, test_doctest
return doctest.testmod(test_doctest)
if __name__ == "__main__":
_test()
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-18 18:01
Message:
Logged In: YES
user_id=6380
Why not just close this as Rejected?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-06-04 11:32
Message:
Logged In: YES
user_id=31435
Should have assigned this back to Trent months ago.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-03-16 21:04
Message:
Logged In: YES
user_id=31435
Trent, yuck. doctests are primarily documentation, and
there's nothing about "." that suggests-- let alone
screams --"ah, this line is really a blank line, not the
period that it sure looks like". Too confusing.
I'd be happy with this if it *screamed* "blank line",
though! For example, accept
<really a blank line>
as meaning it's really a blank line. In that case, though,
note that:
1. The restriction about blank lines is documented in both
doctest's docstrings and in the Library Manual, so this
would also need doc changes in both places.
and
2. doctest is self-testing, i.e. the standard test for
doctest simply runs doctest on doctest. So in the very
same place you document your blank line convention in the
doctest docstring, you should also include an executable
doctest example in the docstring. Then the standard
test_doctest.py will verify that it works exactly as
advertised forever more.
----------------------------------------------------------------------
Comment By: Trent Mick (tmick)
Date: 2001-03-11 13:40
Message:
Logged In: YES
user_id=34892
Grrr, the code I put in the comment is supposed to be
indented of course. I will attach the test_doctest.py to
clarify.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=407764&group_id=5470