Use pytest_collection_modifyitems in a plugin #10585
-
Hello everyone, foo_plugin.py class FooPlugin:
def __init__(self, config: Config) -> None:
self.config = config
@hookimpl
def pytest_collection_modifyitems(self, config: Config, items: List[Item]) -> None:
for item in items:
item.add_marker("foo")
@hookimpl
def pytest_configure(self, config: Config) -> None:
line = f"foo(): Mark a test as a member of foo."
config.addinivalue_line("markers", line) plugin.py (entrypoint) from foo_plugin import FooPlugin
def pytest_configure(config: Config) -> None:
fp= FooPlugin(config)
config.pluginmanager.register(fp, "FooPlugin") I've a small test using pytester and added breakpoint in both Thanks for your help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Works for me (with your |
Beta Was this translation helpful? Give feedback.
Works for me (with your
plugin.py
asconftest.py
). Can you try inserting a1/0
there to make sure it's really not triggered? With apytest --debug
you should get apytestdebug.log
which could tell you more.