7 Jul
2010
7 Jul
'10
2:50 p.m.
On Wed, Jul 7, 2010 at 9:59 AM, Tres Seaver <tseaver@palladion.com> wrote:
Individual test modules can do this, but I'm uncomfortable having a test script make a global setting like this and the warning module doesn't seem to provide a way to capture the current state so it can be reset after running tests.
As of Python 2.6, the warnings module sports a context manager::
with warnings.catch_warnings(): warnings.simplefilter("default") fxn()
Ah, this works because catch_warnings saves and later restores the filter configuration. Cool. Jim -- Jim Fulton