conftest.py 549 B

12345678910111213141516171819202122232425
  1. import pytest
  2. from pluggy import HookspecMarker
  3. from pluggy import PluginManager
  4. @pytest.fixture(
  5. params=[lambda spec: spec, lambda spec: spec()],
  6. ids=["spec-is-class", "spec-is-instance"],
  7. )
  8. def he_pm(request, pm: PluginManager) -> PluginManager:
  9. hookspec = HookspecMarker("example")
  10. class Hooks:
  11. @hookspec
  12. def he_method1(self, arg: int) -> int:
  13. return arg + 1
  14. pm.add_hookspecs(request.param(Hooks))
  15. return pm
  16. @pytest.fixture
  17. def pm() -> PluginManager:
  18. return PluginManager("example")