From 672a98b4fce837957506e2b2ea4ea3e4ceefd5fd Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Aug 2017 20:39:54 -0300 Subject: [PATCH 1/3] Fix error while issuing DeprecationWarning for __multicall__ usage Fix #75 --- pluggy/__init__.py | 2 +- testing/test_pluginmanager.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pluggy/__init__.py b/pluggy/__init__.py index 740f63ce..ef324810 100644 --- a/pluggy/__init__.py +++ b/pluggy/__init__.py @@ -657,7 +657,7 @@ def _add_hookimpl(self, hookimpl): warnings.warn( "Support for __multicall__ is now deprecated and will be" "removed in an upcoming release.", - warnings.DeprecationWarning + DeprecationWarning ) self.multicall = _LegacyMultiCall diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index a362de2f..26878cec 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -337,6 +337,18 @@ class PluginNo(object): assert l == [10] +def test_multicall_deprecated(pm): + class P1(object): + @hookimpl + def m(self, __multicall__, x): + assert len(__multicall__.results) == 1 + assert not __multicall__.hook_impls + return 17 + + with pytest.deprecated_call(): + pm.register(P1()) + + def test_add_hookspecs_nohooks(pm): with pytest.raises(ValueError): pm.add_hookspecs(10) From dc6ae62f6f92d250a18a4dfc7a9b2bc9607bcb1d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Aug 2017 20:53:55 -0300 Subject: [PATCH 2/3] Use function-form of deprecated_call to comply with older pytest versions --- testing/test_pluginmanager.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 26878cec..5d875b9d 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -345,8 +345,7 @@ def m(self, __multicall__, x): assert not __multicall__.hook_impls return 17 - with pytest.deprecated_call(): - pm.register(P1()) + pytest.deprecated_call(pm.register, P1()) def test_add_hookspecs_nohooks(pm): From bf3f0bab059abd1ce8078602603459987be86b2c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Aug 2017 22:07:05 -0300 Subject: [PATCH 3/3] Simplify test --- testing/test_pluginmanager.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 5d875b9d..922fc078 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -341,9 +341,7 @@ def test_multicall_deprecated(pm): class P1(object): @hookimpl def m(self, __multicall__, x): - assert len(__multicall__.results) == 1 - assert not __multicall__.hook_impls - return 17 + pass pytest.deprecated_call(pm.register, P1())