diff --git a/py/test/plugin/api.py b/py/test/plugin/api.py index 6550864e1..db27921bc 100644 --- a/py/test/plugin/api.py +++ b/py/test/plugin/api.py @@ -69,6 +69,7 @@ class PluginHooks: def pytest_pyfunc_call(self, pyfuncitem, args, kwargs): """ return True if we consumed/did the call to the python function item. """ + pytest_pyfunc_call.firstresult = True def pytest_item_makereport(self, item, excinfo, when, outerr): """ return ItemTestReport for the given test outcome. """ diff --git a/py/test/testing/test_api.py b/py/test/testing/test_api.py new file mode 100644 index 000000000..6ee84f184 --- /dev/null +++ b/py/test/testing/test_api.py @@ -0,0 +1,14 @@ + +class TestPyfuncHooks: + def test_pyfunc_call(self, testdir): + item = testdir.getitem("def test_func(): raise ValueError") + config = item.config + class MyPlugin1: + def pytest_pyfunc_call(self, pyfuncitem, *args, **kwargs): + raise ValueError + class MyPlugin2: + def pytest_pyfunc_call(self, pyfuncitem, *args, **kwargs): + return True + config.pluginmanager.register(MyPlugin1()) + config.pluginmanager.register(MyPlugin2()) + config.api.pytest_pyfunc_call(pyfuncitem=item)