summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Goodlet <tgoodlet@gmail.com>2018-05-17 20:34:33 -0400
committerTyler Goodlet <tgoodlet@gmail.com>2018-05-17 20:38:54 -0400
commitd4065a91668fa5fa3f8ef4b7ae5d2443e78328d7 (patch)
treec988ddc1c5a8250c58dd1d1f0eac21aa207d3cbc
parent45faaeca7ae9da3ed4169b6d7a31df06bac4778d (diff)
downloadpytest-d4065a91668fa5fa3f8ef4b7ae5d2443e78328d7.tar.gz
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
-rw-r--r--_pytest/config.py7
1 files changed, 6 insertions, 1 deletions
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))