This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients jaraco, steven.daprano, tim.peters
Date 2018-01-07.04:35:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515299734.96.0.467229070634.issue32509@psf.upfronthosting.co.za>
In-reply-to
Content
Here's a simple demonstration of the issue:


# --- cut %< ---
import doctest

def hash_files():
    """
    >>> hash_files()  # doctest: +ELLIPSIS
    ...
    d41d8cd98f00b204e9800998ecf8427e __init__.py
    ...

    """
    print("""\
e1f9390d13c90c7ed601afffd1b9a9f9 records.py
6a116973e8f29c923a08c2be69b11859 ledger.py
d41d8cd98f00b204e9800998ecf8427e __init__.py
b83c8a54d6b71e28ccb556a828e3fa5e qif.py
ac2d598f65b6debe9888aafe51e9570f ofx.py
9f2572f761342d38239a1394f4337165 msmoney.py
""")

doctest.run_docstring_examples(hash_files, globals())

# --- cut %< ---


The documentation does say that output must follow the final >>> or ... 

https://docs.python.org/3/library/doctest.html#how-are-docstring-examples-recognized

so I believe this is expected behaviour and not a bug.

Here is a workaround. Change the doctest to something like this:


    >>> print('#', end=''); hash_files()  # doctest: +ELLIPSIS
    #...
    d41d8cd98f00b204e9800998ecf8427e __init__.py
    ...



But a more elegant solution would be to add a new directive to tell doctest to interpret the ... or >>> as output, not input, or to add a new symbol similar to <BLANKLINE>.

I'm changing this to an enhancement request as I think this would be useful.
History
Date User Action Args
2018-01-07 04:35:35steven.dapranosetrecipients: + steven.daprano, tim.peters, jaraco
2018-01-07 04:35:34steven.dapranosetmessageid: <1515299734.96.0.467229070634.issue32509@psf.upfronthosting.co.za>
2018-01-07 04:35:34steven.dapranolinkissue32509 messages
2018-01-07 04:35:33steven.dapranocreate