Logged In: YES
user_id=31435
doctest doesn't support mixing "expected normal output" with
an exception, regardless of how such a thing may arise. For
example, this one-liner can't work either as a doctest:
>>> print 'hi', 1/0
hi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
So there's nothing specific to generators in this, rather
it's a doctest limitation. The docs do say, wrt testing
exceptions:
"""
No problem, provided that the traceback is the only output
produced by the example: just paste in the traceback.
"""
In any case, it wasn't intended that doctest support this,
and the docs do try to communicate that. I added text
spelling out the other half (if there's expected output in
addition to the traceback, problem ;-)), in rev 45677 on the
trunk and rev 45678 on the 2.4 branch, and am closing this
report as a doc bug.
Edward Loper tried supporting this, as a new feature, before
2.4 was released, but it so grossly complicated the docs and
the implementation that we agreed to drop it. So you could
re-open this as a feature request, but it's unlikely to change.
|