This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients charlax, cjw296, docs@python, georg.brandl, terry.reedy, tim.peters
Date 2011-03-09.23:02:15
SpamBayes Score 7.785825e-09
Marked as misclassified No
Message-id <1299711739.47.0.107145640129.issue3722@psf.upfronthosting.co.za>
In-reply-to
Content
Temporary output will break all doctests, not just those with exception traceback. One should fix, disable debug output, and then rerun doctest to make sure fix did not break anything else.

A function that prints and raises *can* be tested as by separately testing both output and silencing of expected exception as follows:

>>> def test():
...   print("hello")
...   raise IndexError()
...
>>> try:
...   test()
...   raise BaseException()
... except IndexError:
...   pass
hello

This passes but will not if function prints anything else or does anything other than raise that exception (or a subclass thereof). In practice, catching subclasses should be ok, but if not, the except clause can be expanded to

... except IndexError as msg:
...   if type(msg) is not IndexError:
...     raise BaseException

I am only leaving this open for a possible doc addition showing something like the simpler fix above.
History
Date User Action Args
2011-03-09 23:02:19terry.reedysetrecipients: + terry.reedy, tim.peters, georg.brandl, cjw296, charlax, docs@python
2011-03-09 23:02:19terry.reedysetmessageid: <1299711739.47.0.107145640129.issue3722@psf.upfronthosting.co.za>
2011-03-09 23:02:15terry.reedylinkissue3722 messages
2011-03-09 23:02:15terry.reedycreate