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.

Title: doctest handle ignored execption
Type: enhancement Stage: resolved
Components: Tests Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Yoav.Caspi, r.david.murray
Priority: normal Keywords:

Created on 2014-10-06 14:06 by Yoav.Caspi, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg228685 - (view) Author: Yoav Caspi (Yoav.Caspi) Date: 2014-10-06 14:06
When implementing a class with a __del__ function that raise an exception the exception ignored.
is it possible to add this printed message to be tested by doc test?

something like when running this script the script will pass:
Usage Example:
    >>> cls = Module()
    >>> del cls
    Exception Exception: Exception('oops',) in <bound method Module.__del__ of <__main__.Module object at 0x000000000XXXXXXX>> ignored

class Module(object):
    def __del__(self):
        raise Exception("oops")

if __name__ == '__main__':
    from doctest import testmod
    print testmod()
msg228686 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-06 14:13
This tracker is not a place to get answers to questions, you should use the python-list mailing list for that.  (That said, here's a hint: the only way to capture that message is to run it in a subprocess; the message is generated asynchronously, during garbage collection.)
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66757
2014-10-06 14:13:57r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg228686

resolution: not a bug
stage: resolved
2014-10-06 14:06:46Yoav.Caspicreate