[issue3781] warnings.catch_warnings fails gracelessly when recording warnings but no warnings are emitted

Nick Coghlan report at bugs.python.org
Tue Sep 9 16:53:21 CEST 2008


Nick Coghlan <ncoghlan at gmail.com> added the comment:

In working on the reversion patch, I just noticed that r66321 also
incorrectly removed a whole pile of w.reset() calls.

When using a single catch_warning() context to test two or more
operations which may raise the same warning, you *must* call w.reset()
between each operation, or the later operations can fail to raise
warnings, but the test will still pass because the most recent warning
is still one which was correctly raised by an earlier operation.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3781>
_______________________________________


More information about the Python-bugs-list mailing list