Skip to content

Commit dbda5aa

Browse files
author
Tyler Goodlet
committed
Move deprecation warnings tests to a module
1 parent 8573118 commit dbda5aa

File tree

4 files changed

+54
-46
lines changed

4 files changed

+54
-46
lines changed

testing/test_deprecations.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Deprecation warnings testing roundup.
3+
"""
4+
import pytest
5+
from pluggy.callers import _Result
6+
from pluggy import PluginManager, HookimplMarker, HookspecMarker
7+
8+
hookspec = HookspecMarker("example")
9+
hookimpl = HookimplMarker("example")
10+
11+
12+
def test_result_deprecated():
13+
r = _Result(10, None)
14+
with pytest.deprecated_call():
15+
assert r.result == 10
16+
17+
18+
def test_implprefix_deprecated():
19+
with pytest.deprecated_call():
20+
pm = PluginManager('blah', implprefix='blah_')
21+
22+
class Plugin:
23+
def blah_myhook(self, arg1):
24+
return arg1
25+
26+
with pytest.deprecated_call():
27+
pm.register(Plugin())
28+
29+
30+
def test_callhistoric_proc_deprecated(pm):
31+
"""``proc`` kwarg to `PluginMananger.call_historic()` is now officially
32+
deprecated.
33+
"""
34+
class P1(object):
35+
@hookspec(historic=True)
36+
@hookimpl
37+
def m(self, x):
38+
pass
39+
40+
p1 = P1()
41+
pm.add_hookspecs(p1)
42+
pm.register(p1)
43+
with pytest.deprecated_call():
44+
pm.hook.m.call_historic(kwargs=dict(x=10), proc=lambda res: res)
45+
46+
47+
def test_multicall_deprecated(pm):
48+
class P1(object):
49+
@hookimpl
50+
def m(self, __multicall__, x):
51+
pass
52+
53+
pytest.deprecated_call(pm.register, P1())

testing/test_details.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import warnings
22
import pytest
33
from pluggy import PluginManager, HookimplMarker, HookspecMarker
4-
from pluggy.callers import _Result
54

65
hookspec = HookspecMarker("example")
76
hookimpl = HookimplMarker("example")
@@ -118,21 +117,3 @@ def myhook(self, arg1):
118117
warning = warns[-1]
119118
assert issubclass(warning.category, Warning)
120119
assert "Argument(s) ('arg2',)" in str(warning.message)
121-
122-
123-
def test_result_deprecated():
124-
r = _Result(10, None)
125-
with pytest.deprecated_call():
126-
assert r.result == 10
127-
128-
129-
def test_implprefix_deprecated():
130-
with pytest.deprecated_call():
131-
pm = PluginManager('blah', implprefix='blah_')
132-
133-
class Plugin:
134-
def blah_myhook(self, arg1):
135-
return arg1
136-
137-
with pytest.deprecated_call():
138-
pm.register(Plugin())

testing/test_hookcaller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def he_myhook1(arg1):
179179
assert not hasattr(he_myhook1, name)
180180

181181

182-
def test_happypath(pm):
182+
def test_hookrelay_registry(pm):
183183
"""Verify hook caller instances are registered by name onto the relay
184184
and can be likewise unregistered."""
185185
class Api(object):

testing/test_pluginmanager.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,6 @@ class PluginNo(object):
374374
assert out == [10]
375375

376376

377-
def test_multicall_deprecated(pm):
378-
class P1(object):
379-
@hookimpl
380-
def m(self, __multicall__, x):
381-
pass
382-
383-
pytest.deprecated_call(pm.register, P1())
384-
385-
386377
def test_add_hookspecs_nohooks(pm):
387378
with pytest.raises(ValueError):
388379
pm.add_hookspecs(10)
@@ -411,23 +402,6 @@ def example_hook():
411402
assert pm.parse_hookimpl_opts(conftest, 'example_hook') == {}
412403

413404

414-
def test_callhistoric_proc_deprecated(pm):
415-
"""``proc`` kwarg to `PluginMananger.call_historic()` is now officially
416-
deprecated.
417-
"""
418-
class P1(object):
419-
@hookspec(historic=True)
420-
@hookimpl
421-
def m(self, x):
422-
pass
423-
424-
p1 = P1()
425-
pm.add_hookspecs(p1)
426-
pm.register(p1)
427-
with pytest.deprecated_call():
428-
pm.hook.m.call_historic(kwargs=dict(x=10), proc=lambda res: res)
429-
430-
431405
def test_load_setuptools_instantiation(monkeypatch, pm):
432406
pkg_resources = pytest.importorskip("pkg_resources")
433407

0 commit comments

Comments
 (0)