print followed by exception eats print

Bug #262578 reported by ChrisW
2
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-3.6.0-py2.4.egg\zope\te
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
Revision history for this message
ChrisW (chris-simplistix) wrote :

This also affects Python's doctest:

http://bugs.python.org/issue3722

Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.testing project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.testing.

Changed in zope.testing:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.