fix hookspec parsing
This commit is contained in:
parent
9f9f6ee48b
commit
3947b859dc
|
@ -268,10 +268,10 @@ class PytestPluginManager(PluginManager):
|
||||||
# collect unmarked hooks as long as they have the `pytest_' prefix
|
# collect unmarked hooks as long as they have the `pytest_' prefix
|
||||||
if opts is None and name.startswith("pytest_"):
|
if opts is None and name.startswith("pytest_"):
|
||||||
opts = {}
|
opts = {}
|
||||||
|
|
||||||
if opts is not None:
|
if opts is not None:
|
||||||
# TODO: DeprecationWarning, people should use hookimpl
|
# TODO: DeprecationWarning, people should use hookimpl
|
||||||
known_marks = {m.name for m in getattr(method, "pytestmark", [])}
|
known_marks = {m.name for m in getattr(method, "pytestmark", [])}
|
||||||
|
|
||||||
for name in ("tryfirst", "trylast", "optionalhook", "hookwrapper"):
|
for name in ("tryfirst", "trylast", "optionalhook", "hookwrapper"):
|
||||||
|
|
||||||
opts.setdefault(name, hasattr(method, name) or name in known_marks)
|
opts.setdefault(name, hasattr(method, name) or name in known_marks)
|
||||||
|
@ -283,10 +283,15 @@ class PytestPluginManager(PluginManager):
|
||||||
)
|
)
|
||||||
if opts is None:
|
if opts is None:
|
||||||
method = getattr(module_or_class, name)
|
method = getattr(module_or_class, name)
|
||||||
|
|
||||||
if name.startswith("pytest_"):
|
if name.startswith("pytest_"):
|
||||||
|
# todo: deprecate hookspec hacks
|
||||||
|
known_marks = {m.name for m in getattr(method, "pytestmark", [])}
|
||||||
opts = {
|
opts = {
|
||||||
"firstresult": hasattr(method, "firstresult"),
|
"firstresult": hasattr(method, "firstresult")
|
||||||
"historic": hasattr(method, "historic"),
|
or "firstresult" in known_marks,
|
||||||
|
"historic": hasattr(method, "historic")
|
||||||
|
or "historic" in known_marks,
|
||||||
}
|
}
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue