[issue3780] No way to write unit tests for warnings
report at bugs.python.org
Thu Sep 4 23:59:47 CEST 2008
New submission from Jean-Paul Calderone <exarkun at divmod.com>:
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
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)
title: No way to write unit tests for warnings
versions: Python 2.6
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list