diff --git a/AUTHORS b/AUTHORS index be4cd290dac..ca82b483f53 100644 --- a/AUTHORS +++ b/AUTHORS @@ -42,6 +42,7 @@ Marc Schlaich Mark Abramowitz Martijn Faassen Nicolas Delaby +Pieter Mulder Piotr Banaszkiewicz Punyashloka Biswal Ralf Schmitt diff --git a/CHANGELOG b/CHANGELOG index 1023fd95f6c..88d21d68426 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ 2.7.2 (compared to 2.7.1) ----------------------------- +- preserve warning functions after call to pytest.deprecated_call + - fix issue767: pytest.raises value attribute does not contain the exception instance on Python 2.6. Thanks Eric Siegerman for providing the test case and Bruno Oliveira for PR. diff --git a/_pytest/recwarn.py b/_pytest/recwarn.py index 482b78b0eb0..875cb510e75 100644 --- a/_pytest/recwarn.py +++ b/_pytest/recwarn.py @@ -45,8 +45,8 @@ def warn(*args, **kwargs): try: ret = func(*args, **kwargs) finally: - warnings.warn_explicit = warn_explicit - warnings.warn = warn + warnings.warn_explicit = oldwarn_explicit + warnings.warn = oldwarn if not l: __tracebackhide__ = True raise AssertionError("%r did not produce DeprecationWarning" %(func,)) diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index d8fe1784e54..d3455946fa4 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -64,12 +64,12 @@ def test_deprecated_call_ret(): assert ret == 42 def test_deprecated_call_preserves(): - r = py.std.warnings.onceregistry.copy() - f = py.std.warnings.filters[:] + warn = py.std.warnings.warn + warn_explicit = py.std.warnings.warn_explicit test_deprecated_call_raises() test_deprecated_call() - assert r == py.std.warnings.onceregistry - assert f == py.std.warnings.filters + assert warn == py.std.warnings.warn + assert warn_explicit == py.std.warnings.warn_explicit def test_deprecated_explicit_call_raises(): pytest.raises(AssertionError,