Skip to content
Permalink
Browse files

Merge pull request #3487 from tgoodlet/detect_pytest_hook_prefix

Detect `pytest_` prefixed hooks
  • Loading branch information...
RonnyPfannschmidt committed May 22, 2018
2 parents 8e17e32 + 486b786 commit 6c8d46d8ea2341ef20362d8f46665f7e563b9821
Showing with 9 additions and 1 deletion.
  1. +6 −1 _pytest/config.py
  2. +3 −0 changelog/3487.trivial.rst
@@ -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
@@ -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))
@@ -0,0 +1,3 @@
Detect `pytest_` prefixed hooks using the internal plugin
manager since ``pluggy`` is deprecating the ``implprefix``
argument to ``PluginManager``.

0 comments on commit 6c8d46d

Please sign in to comment.
You can’t perform that action at this time.