Closed cjolowicz closed 3 years ago
Does this work with the original doctest module? I would expect using the PS2 ...
to prefix a secondary statement should result in an error. From what I understand it should only be used to denote command continuations. The statement f()
is not a continuation of the previous AST block, so it should be formatted as such:
"""
>>> def f():
... return 42
...
>>> f()
42
"""
Alternatively, you can simply use the new xdoctest prefix rule (Use >>>
for everything), and it will work.
"""
>>> def f():
>>> return 42
>>> f()
42
"""
However, if your example does work with the original doctest module, then we should consider supporting it.
You're entirely right, and the doctest module has the same behavior here. Thank you for clarifying this!
This module
leads to the following backtrace:
Stepping into the error, it looks like xdoctest invokes
compile
in single mode even though multiple statements are present.This does not happen when only PS1 is used.