On Wed, Jul 07, 2010 at 02:43:14PM +0200, Hanno Schlichting wrote:
On Wed, Jul 7, 2010 at 12:55 PM, Jim Fulton <jim@zope.com> wrote:
I'm not sure what the best way to handle this is. My initial thought is that all test runners should enable deprecations by default. This seems hard to enforce.
What about letting the testrunner (zope.testing / zope.testrunner) enable deprecation warnings by default, but add a command line switch to disable them or use the Python default?
+1 Although tests that check for functions emitting DeprecationWarnings should not rely on this; they should explicitly ensure DeprecationWarnings are not filtered away in their own setup.
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.
There's the warnings.catch_warnings context manager (since Python 2.6): http://docs.python.org/library/warnings.html#testing-warnings I'm sure it can be backported to older Python versions, or the test setUp/tearDown can fiddle with warnings.filters[:] directly. Marius Gedminas -- http://pov.lt/ -- Zope 3 consulting and development