Skip to content

Commit 4194c9c

Browse files
committed
Check deprecated_call specific to deprecation
`deprecated_call` used to accept any warning. As of pytest-dev#897, it is now specific to DeprecationWarnings, and another commit in this PR extends this to PendingDeprecationWarnings. This commit makes sure this stays the case.
1 parent e8261e0 commit 4194c9c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
2.8.1.dev
22
---------
33

4+
- 'deprecated_call' is now only satisfied with a DeprecationWarning or
5+
PendingDeprecationWarning. Before 2.8.0, it accepted any warning, and 2.8.0
6+
made it accept only DeprecationWarning (but not PendingDeprecationWarning).
7+
Thanks Alex Gaynor for the issue and Eric Hunsberger for the PR.
8+
49
- fix issue #1073: avoid calling __getattr__ on potential plugin objects.
510
This fixes an incompatibility with pytest-django. Thanks Andreas Pelme,
611
Bruno Oliveira and Ronny Pfannschmidt for contributing and Holger Krekel

testing/test_recwarn.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ def test_deprecated_call_pending(self):
115115
f = lambda: py.std.warnings.warn(PendingDeprecationWarning("hi"))
116116
pytest.deprecated_call(f)
117117

118+
def test_deprecated_call_specificity(self):
119+
other_warnings = [Warning, UserWarning, SyntaxWarning, RuntimeWarning,
120+
FutureWarning, ImportWarning, UnicodeWarning]
121+
for warning in other_warnings:
122+
f = lambda: py.std.warnings.warn(warning("hi"))
123+
with pytest.raises(AssertionError):
124+
pytest.deprecated_call(f)
125+
118126

119127
class TestWarns(object):
120128
def test_strings(self):

0 commit comments

Comments
 (0)