Merge pull request #1241 from nicoddemus/fix-deprecated-call-args

Fix deprecated_call regression introduced in 2.8.4
This commit is contained in:
Ronny Pfannschmidt 2015-12-09 06:48:43 +01:00
commit 1c70827f33
3 changed files with 10 additions and 5 deletions

View File

@ -4,6 +4,10 @@
- fix #1074: precompute junitxml chunks instead of storing the whole tree in objects - fix #1074: precompute junitxml chunks instead of storing the whole tree in objects
Thanks Bruno Oliveira for the report and Ronny Pfannschmidt for the PR Thanks Bruno Oliveira for the report and Ronny Pfannschmidt for the PR
- fix #1238: fix ``pytest.deprecated_call()`` receiving multiple arguments
(Regression introduced in 2.8.4). Thanks Alex Gaynor for the report and
Bruno Oliveira for the PR.
2.8.4 2.8.4
----- -----

View File

@ -42,7 +42,7 @@ def deprecated_call(func, *args, **kwargs):
categories.append(category) categories.append(category)
old_warn_explicit(message, category, *args, **kwargs) old_warn_explicit(message, category, *args, **kwargs)
def warn(message, category=None, **kwargs): def warn(message, category=None, *args, **kwargs):
if isinstance(message, Warning): if isinstance(message, Warning):
categories.append(message.__class__) categories.append(message.__class__)
else: else:

View File

@ -67,9 +67,10 @@ class TestWarningsRecorderChecker(object):
class TestDeprecatedCall(object): class TestDeprecatedCall(object):
"""test pytest.deprecated_call()""" """test pytest.deprecated_call()"""
def dep(self, i): def dep(self, i, j=None):
if i == 0: if i == 0:
py.std.warnings.warn("is deprecated", DeprecationWarning) py.std.warnings.warn("is deprecated", DeprecationWarning,
stacklevel=1)
return 42 return 42
def dep_explicit(self, i): def dep_explicit(self, i):
@ -79,11 +80,11 @@ class TestDeprecatedCall(object):
def test_deprecated_call_raises(self): def test_deprecated_call_raises(self):
with pytest.raises(AssertionError) as excinfo: with pytest.raises(AssertionError) as excinfo:
pytest.deprecated_call(self.dep, 3) pytest.deprecated_call(self.dep, 3, 5)
assert str(excinfo).find("did not produce") != -1 assert str(excinfo).find("did not produce") != -1
def test_deprecated_call(self): def test_deprecated_call(self):
pytest.deprecated_call(self.dep, 0) pytest.deprecated_call(self.dep, 0, 5)
def test_deprecated_call_ret(self): def test_deprecated_call_ret(self):
ret = pytest.deprecated_call(self.dep, 0) ret = pytest.deprecated_call(self.dep, 0)