How to make this doctest work?

Xie&Tian mftian at gmail.com
Tue May 11 05:29:25 EDT 2010


Hello

I ran across this accidentally and wonders how to make the doctest in
following code snippet work:


import doctest

def a():
     """
    >>> a = '\\r\\n'
    >>> print a


    No matter how many blank lines I add here, it just can't get enough -_-
    """
    pass

doctest.testmod()



ps: I want variable "a" to be '\r\n', but python kept telling me
        ValueError: line 4 of the docstring has inconsistent leading
whitespace: "'"
    Why can't doctest module deal with statement "a='\r\n'"?

-- 
Luyun Xie
http://magefromhell.blogspot.com/
(http://blog.hellmage.info/)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100511/bc9cf9a0/attachment.html>


More information about the Python-list mailing list