Skip to content

Commit

Permalink
Move deprecation warnings tests to a module
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Goodlet committed May 23, 2018
1 parent 8573118 commit dbda5aa
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
53 changes: 53 additions & 0 deletions testing/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -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())
19 changes: 0 additions & 19 deletions testing/test_details.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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())
2 changes: 1 addition & 1 deletion testing/test_hookcaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
26 changes: 0 additions & 26 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit dbda5aa

Please sign in to comment.