[Zope-dev] Python 2.7 disables deprecation warnings by default
Jim Fulton
jim at zope.com
Wed Jul 7 10:50:25 EDT 2010
On Wed, Jul 7, 2010 at 9:59 AM, Tres Seaver <tseaver at 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
More information about the Zope-Dev
mailing list