test_deprecations.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """
  2. Deprecation warnings testing roundup.
  3. """
  4. import pytest
  5. from pluggy.callers import _Result
  6. from pluggy import PluginManager, HookimplMarker, HookspecMarker
  7. hookspec = HookspecMarker("example")
  8. hookimpl = HookimplMarker("example")
  9. def test_result_deprecated():
  10. r = _Result(10, None)
  11. with pytest.deprecated_call():
  12. assert r.result == 10
  13. def test_implprefix_deprecated():
  14. with pytest.deprecated_call():
  15. pm = PluginManager("blah", implprefix="blah_")
  16. class Plugin:
  17. def blah_myhook(self, arg1):
  18. return arg1
  19. with pytest.deprecated_call():
  20. pm.register(Plugin())
  21. def test_callhistoric_proc_deprecated(pm):
  22. """``proc`` kwarg to `PluginMananger.call_historic()` is now officially
  23. deprecated.
  24. """
  25. class P1(object):
  26. @hookspec(historic=True)
  27. @hookimpl
  28. def m(self, x):
  29. pass
  30. p1 = P1()
  31. pm.add_hookspecs(p1)
  32. pm.register(p1)
  33. with pytest.deprecated_call():
  34. pm.hook.m.call_historic(kwargs=dict(x=10), proc=lambda res: res)
  35. def test_multicall_deprecated(pm):
  36. class P1(object):
  37. @hookimpl
  38. def m(self, __multicall__, x):
  39. pass
  40. pytest.deprecated_call(pm.register, P1())