[Python-Dev] doctest improvements

Edward Loper edloper at gradient.cis.upenn.edu
Mon May 31 14:06:12 EDT 2004


About a month and a half ago, I filed several patches for doctest, and 
they haven't gotten any comments; so I was wondering if anyone could 
look at them.

The most interesting is #933238, which addresses the often-noted problem 
that doctest can't handle blank lines.  It adds a special blank-line 
marker (currently "-"), which must be *dedented* with respect to the 
doctest block.  Here's an example use (the "x"s are to prevent mail 
readers from interpreting ">>>" as a quotation).

x    def test_blankline_marker():
x        r"""
x        Use a dedented "-" to signify a blank line:
x
x            >>> print 'First line\n\nThis is after a blank line\n'
x            First line
x           -
x            This is after a blank line
x           -
x        """

(Note that both internal and trailing blank lines can be handled.)

This change is backwards compatible, since currently any line in a 
doctest block that's dedented past the prompt (">>>") is an error.

If anyone has time to take a look at this, let me know what you think. 
Thanks.

-Edward

My doctest patches:

[ 933238 ] doctest: add a special (dedented) marker for blank lines
http://sourceforge.net/tracker/?func=detail&aid=933238&group_id=5470&atid=305470

[ 932930 ] doctest: suggest the use of rawstrings for backslashes
http://sourceforge.net/tracker/?func=detail&aid=932930&group_id=5470&atid=305470

[ 932935 ] doctest: allow custom matchers for testing if got==want
http://sourceforge.net/tracker/?func=detail&aid=932935&group_id=5470&atid=305470

[ 932932 ] doctest: Add Tester params to DocTestSuite
http://sourceforge.net/tracker/?func=detail&aid=932932&group_id=5470&atid=305470



More information about the Python-Dev mailing list