Message309603
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. |
|
Date |
User |
Action |
Args |
2018-01-07 04:35:35 | steven.daprano | set | recipients:
+ steven.daprano, tim.peters, jaraco |
2018-01-07 04:35:34 | steven.daprano | set | messageid: <1515299734.96.0.467229070634.issue32509@psf.upfronthosting.co.za> |
2018-01-07 04:35:34 | steven.daprano | link | issue32509 messages |
2018-01-07 04:35:33 | steven.daprano | create | |
|