diff --git a/testing/test_deprecations.py b/testing/test_deprecations.py new file mode 100644 index 00000000..3000a374 --- /dev/null +++ b/testing/test_deprecations.py @@ -0,0 +1,53 @@ +""" +Deprecation warnings testing roundup. +""" +import pytest +from pluggy.callers import _Result +from pluggy import PluginManager, HookimplMarker, HookspecMarker + +hookspec = HookspecMarker("example") +hookimpl = HookimplMarker("example") + + +def test_result_deprecated(): + r = _Result(10, None) + with pytest.deprecated_call(): + assert r.result == 10 + + +def test_implprefix_deprecated(): + with pytest.deprecated_call(): + pm = PluginManager('blah', implprefix='blah_') + + class Plugin: + def blah_myhook(self, arg1): + return arg1 + + with pytest.deprecated_call(): + pm.register(Plugin()) + + +def test_callhistoric_proc_deprecated(pm): + """``proc`` kwarg to `PluginMananger.call_historic()` is now officially + deprecated. + """ + class P1(object): + @hookspec(historic=True) + @hookimpl + def m(self, x): + pass + + p1 = P1() + pm.add_hookspecs(p1) + pm.register(p1) + with pytest.deprecated_call(): + pm.hook.m.call_historic(kwargs=dict(x=10), proc=lambda res: res) + + +def test_multicall_deprecated(pm): + class P1(object): + @hookimpl + def m(self, __multicall__, x): + pass + + pytest.deprecated_call(pm.register, P1()) diff --git a/testing/test_details.py b/testing/test_details.py index 179dde6b..66a1b65f 100644 --- a/testing/test_details.py +++ b/testing/test_details.py @@ -1,7 +1,6 @@ import warnings import pytest from pluggy import PluginManager, HookimplMarker, HookspecMarker -from pluggy.callers import _Result hookspec = HookspecMarker("example") hookimpl = HookimplMarker("example") @@ -118,21 +117,3 @@ def myhook(self, arg1): warning = warns[-1] assert issubclass(warning.category, Warning) assert "Argument(s) ('arg2',)" in str(warning.message) - - -def test_result_deprecated(): - r = _Result(10, None) - with pytest.deprecated_call(): - assert r.result == 10 - - -def test_implprefix_deprecated(): - with pytest.deprecated_call(): - pm = PluginManager('blah', implprefix='blah_') - - class Plugin: - def blah_myhook(self, arg1): - return arg1 - - with pytest.deprecated_call(): - pm.register(Plugin()) diff --git a/testing/test_hookcaller.py b/testing/test_hookcaller.py index 5f3b1e58..a58e6402 100644 --- a/testing/test_hookcaller.py +++ b/testing/test_hookcaller.py @@ -179,7 +179,7 @@ def he_myhook1(arg1): assert not hasattr(he_myhook1, name) -def test_happypath(pm): +def test_hookrelay_registry(pm): """Verify hook caller instances are registered by name onto the relay and can be likewise unregistered.""" class Api(object): diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index dd63d4df..f04300be 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -374,15 +374,6 @@ class PluginNo(object): assert out == [10] -def test_multicall_deprecated(pm): - class P1(object): - @hookimpl - def m(self, __multicall__, x): - pass - - pytest.deprecated_call(pm.register, P1()) - - def test_add_hookspecs_nohooks(pm): with pytest.raises(ValueError): pm.add_hookspecs(10) @@ -411,23 +402,6 @@ def example_hook(): assert pm.parse_hookimpl_opts(conftest, 'example_hook') == {} -def test_callhistoric_proc_deprecated(pm): - """``proc`` kwarg to `PluginMananger.call_historic()` is now officially - deprecated. - """ - class P1(object): - @hookspec(historic=True) - @hookimpl - def m(self, x): - pass - - p1 = P1() - pm.add_hookspecs(p1) - pm.register(p1) - with pytest.deprecated_call(): - pm.hook.m.call_historic(kwargs=dict(x=10), proc=lambda res: res) - - def test_load_setuptools_instantiation(monkeypatch, pm): pkg_resources = pytest.importorskip("pkg_resources")