New submission from Jean-Paul Calderone <[EMAIL PROTECTED]>: In Python 2.5 and earlier, the `warnings.warn_explicit` function could be replaced in order to test what warnings were emitted by some code. This allowed unit tests for warnings to be written. Since much of the warnings module was re-implemented in C, replacing `warnings.warn_explicit` no longer has any effect. This, together with the fact that there are no other public APIs for hooking into the warning system with duplication suppression disabled means that there is no reliable way to write unit tests for warnings.
This was previously discussed on python-dev, but no conclusion was reached. See http://mail.python.org/pipermail/python-dev/2008-June/080635.html and the follow-ups. For Twisted, the consequence of this is roughly 79 failing unit tests in Python 2.6b3 and no clear way to fix them, except to stop using the standard library warnings module. ---------- components: Library (Lib) messages: 72530 nosy: exarkun severity: normal status: open title: No way to write unit tests for warnings type: behavior versions: Python 2.6 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3780> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com