summaryrefslogtreecommitdiff
path: root/testing/test_recwarn.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2017-05-29 22:46:15 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2017-05-30 12:52:18 -0300
commitf96a1d89c5e8a76708b686c09c16a8017292bf40 (patch)
treee9145363be799e30fb9621e21b54cad2a22f6afd /testing/test_recwarn.py
parentee0844dbd837454bde3265af4e67b634e410331a (diff)
downloadpytest-f96a1d89c5e8a76708b686c09c16a8017292bf40.tar.gz
pytest.deprecated_call now captures PendingDeprecationWarning in context manager form
Fix #2441
Diffstat (limited to 'testing/test_recwarn.py')
-rw-r--r--testing/test_recwarn.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py
index 0f921f057..2a379c6ce 100644
--- a/testing/test_recwarn.py
+++ b/testing/test_recwarn.py
@@ -109,14 +109,17 @@ class TestDeprecatedCall(object):
with pytest.deprecated_call():
self.dep(1)
- def test_deprecated_call_as_context_manager(self):
- with pytest.deprecated_call():
- self.dep(0)
-
- def test_deprecated_call_pending(self):
+ @pytest.mark.parametrize('warning_type', [PendingDeprecationWarning, DeprecationWarning])
+ @pytest.mark.parametrize('mode', ['context_manager', 'call'])
+ def test_deprecated_call_modes(self, warning_type, mode):
def f():
- py.std.warnings.warn(PendingDeprecationWarning("hi"))
- pytest.deprecated_call(f)
+ warnings.warn(warning_type("hi"))
+
+ if mode == 'call':
+ pytest.deprecated_call(f)
+ else:
+ with pytest.deprecated_call():
+ f()
def test_deprecated_call_specificity(self):
other_warnings = [Warning, UserWarning, SyntaxWarning, RuntimeWarning,