print followed by exception eats print
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zope.testing |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Here's an example from a python interpreter session:
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def test():
... print "hello"
... raise Exception()
...
>>> test()
hello
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in test
Exception
...which doesn't behave the same as a doctest:
Failed example:
test()
Exception raised:
Traceback (most recent call last):
File "zope.testing-
sting\doctest.py", line 1356, in __run
File "<doctest readme.txt[8]>", line 1, in ?
test()
File "<doctest readme.txt[7]>", line 3, in test
raise Exception()
Exception
The problem is that the function prints output before raising the
exception. If I take the printed output away, the doctest passes fine.
However, especially with dummy fixtures common in doctests, that printed
output needs to be seen to test that things are happening as they should
prior to the exception being raised.
Changed in zope.testing: | |
status: | New → Confirmed |
This also affects Python's doctest:
http:// bugs.python. org/issue3722