From d4065a91668fa5fa3f8ef4b7ae5d2443e78328d7 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 May 2018 20:34:33 -0400 Subject: [PATCH 1/2] Detect `pytest_` prefixed hooks `pluggy` is deprecating the `implprefix` argument in the next major release so implement this detection in our derived plugin manager. Relates to pytest-dev/pluggy#145 --- _pytest/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_pytest/config.py b/_pytest/config.py index eb9c2a1f2..86632ed64 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -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 @@ class PytestPluginManager(PluginManager): 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)) From 486b786cb22e037fc76f210a8c00ab7d42c83a49 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 18 May 2018 12:02:50 -0400 Subject: [PATCH 2/2] Add trivial changelog entry --- changelog/3487.trivial.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/3487.trivial.rst diff --git a/changelog/3487.trivial.rst b/changelog/3487.trivial.rst new file mode 100644 index 000000000..b6dd840f8 --- /dev/null +++ b/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``.