From 2fd437e465436000af9b625e3755c4235bad3eb3 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 17 Apr 2009 19:25:15 +0200 Subject: [PATCH] ref addresses 4 The first non-None value returned by a pytest_pyfunc_call hook method now indicates that the function call has been performed. --HG-- branch : trunk --- py/test/plugin/api.py | 1 + py/test/testing/test_api.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 py/test/testing/test_api.py 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)