`deprecated_call` detects pending warnings again
`deprecated_call` now looks for PendingDeprecationWarnings, as it did previously but was broken by #897. Fixes #1037. Also added a test so this does not happen again.
This commit is contained in:
parent
22e1f4946e
commit
e8261e0c77
|
@ -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,10 @@ 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)
|
||||
|
||||
|
||||
class TestWarns(object):
|
||||
def test_strings(self):
|
||||
|
@ -181,4 +185,3 @@ class TestWarns(object):
|
|||
''')
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines(['*2 passed in*'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue