Merge pull request #1081 from hunse/fix-pendingdep
`deprecated_call` detects pending warnings again
This commit is contained in:
commit
839909f3f6
|
@ -1,6 +1,11 @@
|
|||
2.8.1.dev
|
||||
---------
|
||||
|
||||
- 'deprecated_call' is now only satisfied with a DeprecationWarning or
|
||||
PendingDeprecationWarning. Before 2.8.0, it accepted any warning, and 2.8.0
|
||||
made it accept only DeprecationWarning (but not PendingDeprecationWarning).
|
||||
Thanks Alex Gaynor for the issue and Eric Hunsberger for the PR.
|
||||
|
||||
- fix issue #1073: avoid calling __getattr__ on potential plugin objects.
|
||||
This fixes an incompatibility with pytest-django. Thanks Andreas Pelme,
|
||||
Bruno Oliveira and Ronny Pfannschmidt for contributing and Holger Krekel
|
||||
|
|
|
@ -36,7 +36,8 @@ def deprecated_call(func, *args, **kwargs):
|
|||
warnings.simplefilter('always') # ensure all warnings are triggered
|
||||
ret = func(*args, **kwargs)
|
||||
|
||||
if not any(r.category is DeprecationWarning for r in wrec):
|
||||
depwarnings = (DeprecationWarning, PendingDeprecationWarning)
|
||||
if not any(r.category in depwarnings for r in wrec):
|
||||
__tracebackhide__ = True
|
||||
raise AssertionError("%r did not produce DeprecationWarning" % (func,))
|
||||
|
||||
|
|
|
@ -111,6 +111,18 @@ class TestDeprecatedCall(object):
|
|||
pytest.deprecated_call(dep_explicit, 0)
|
||||
pytest.deprecated_call(dep_explicit, 0)
|
||||
|
||||
def test_deprecated_call_pending(self):
|
||||
f = lambda: py.std.warnings.warn(PendingDeprecationWarning("hi"))
|
||||
pytest.deprecated_call(f)
|
||||
|
||||
def test_deprecated_call_specificity(self):
|
||||
other_warnings = [Warning, UserWarning, SyntaxWarning, RuntimeWarning,
|
||||
FutureWarning, ImportWarning, UnicodeWarning]
|
||||
for warning in other_warnings:
|
||||
f = lambda: py.std.warnings.warn(warning("hi"))
|
||||
with pytest.raises(AssertionError):
|
||||
pytest.deprecated_call(f)
|
||||
|
||||
|
||||
class TestWarns(object):
|
||||
def test_strings(self):
|
||||
|
@ -181,4 +193,3 @@ class TestWarns(object):
|
|||
''')
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(['*2 passed in*'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue