Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect pytest_ prefixed hooks #3487

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion _pytest/config.py
Expand Up @@ -177,7 +177,7 @@ class PytestPluginManager(PluginManager):
"""

def __init__(self):
super(PytestPluginManager, self).__init__("pytest", implprefix="pytest_")
super(PytestPluginManager, self).__init__("pytest")
self._conftest_plugins = set()

# state related to local conftest plugins
Expand Down Expand Up @@ -231,6 +231,11 @@ def parse_hookimpl_opts(self, plugin, name):

method = getattr(plugin, name)
opts = super(PytestPluginManager, self).parse_hookimpl_opts(plugin, name)

# collect unmarked hooks as long as they have the `pytest_' prefix
if opts is None and name.startswith("pytest_"):
opts = {}

if opts is not None:
for name in ("tryfirst", "trylast", "optionalhook", "hookwrapper"):
opts.setdefault(name, hasattr(method, name))
Expand Down
3 changes: 3 additions & 0 deletions changelog/3487.trivial.rst
@@ -0,0 +1,3 @@
Detect `pytest_` prefixed hooks using the internal plugin
manager since ``pluggy`` is deprecating the ``implprefix``
argument to ``PluginManager``.