diff --git a/py/test/pycollect.py b/py/test/pycollect.py index 24dd5442b..0e21c4d9e 100644 --- a/py/test/pycollect.py +++ b/py/test/pycollect.py @@ -247,7 +247,7 @@ class FunctionMixin(PyobjMixin): obj = self.parent.obj setup_func_or_method = getattr(obj, name, None) if setup_func_or_method is not None: - return setup_func_or_method(self.obj) + setup_func_or_method(self.obj) def teardown(self): """ perform teardown for this test function. """ @@ -345,14 +345,18 @@ class Function(FunctionMixin, py.test.collect.Item): def runtest(self): """ execute the given test function. """ - if not self._deprecated_testexecution(): - self.setupargs() # XXX move to setup() / consider funcargs plugin - ret = self.config.api.pytest_pyfunc_call( - pyfuncitem=self, args=self._args, kwargs=self.funcargs) + self.config.api.pytest_pyfunc_call(pyfuncitem=self, + args=self._args, kwargs=self.funcargs) - def setupargs(self): + def setup(self): + super(Function, self).setup() + self._setupfuncargs() + + def _setupfuncargs(self): if self._args: - # generator case: we don't do anything then + # functions yielded from a generator: we don't want + # to support that because we want to go here anyway: + # http://bitbucket.org/hpk42/py-trunk/issue/2/next-generation-generative-tests pass else: # standard Python Test function/method case diff --git a/py/test/runner.py b/py/test/runner.py index e89f15071..11fb01554 100644 --- a/py/test/runner.py +++ b/py/test/runner.py @@ -20,7 +20,8 @@ def basic_run_report(item, pdb=None): item.config._setupstate.prepare(item) try: when = "execute" - res = item.runtest() + if not item._deprecated_testexecution(): + item.runtest() finally: when = "teardown" item.config._setupstate.teardown_exact(item) diff --git a/py/test/testing/test_deprecated_api.py b/py/test/testing/test_deprecated_api.py index 1c9f83302..d217c4c29 100644 --- a/py/test/testing/test_deprecated_api.py +++ b/py/test/testing/test_deprecated_api.py @@ -105,7 +105,7 @@ class TestCollectDeprecated: funcitem = modcol.collect()[0] assert funcitem.name == 'test_func' recwarn.clear() - funcitem.runtest() + funcitem._deprecated_testexecution() recwarn.pop(DeprecationWarning) def test_function_custom_execute(self, testdir, recwarn): diff --git a/py/test/testing/test_funcargs.py b/py/test/testing/test_funcargs.py index adbc47d4a..9546bce77 100644 --- a/py/test/testing/test_funcargs.py +++ b/py/test/testing/test_funcargs.py @@ -8,7 +8,7 @@ class TestFuncargs: return 42 """) item = testdir.getitem("def test_func(some): pass") - exc = py.test.raises(LookupError, "item.setupargs()") + exc = py.test.raises(LookupError, "item._setupfuncargs()") s = str(exc.value) assert s.find("xyzsomething") != -1 @@ -18,7 +18,7 @@ class TestFuncargs: def pytest_funcarg__some(self, request): return request.function.__name__ item.config.pluginmanager.register(Provider()) - item.setupargs() + item._setupfuncargs() assert len(item.funcargs) == 1 def test_funcarg_lookup_default_gets_overriden(self, testdir): @@ -27,7 +27,7 @@ class TestFuncargs: def pytest_funcarg__other(self, request): return request.function.__name__ item.config.pluginmanager.register(Provider()) - item.setupargs() + item._setupfuncargs() assert len(item.funcargs) == 1 name, value = item.funcargs.popitem() assert name == "other" @@ -41,7 +41,7 @@ class TestFuncargs: def pytest_funcarg__other(self, request): return 42 item.config.pluginmanager.register(Provider()) - item.setupargs() + item._setupfuncargs() assert len(item.funcargs) == 2 assert item.funcargs['some'] == "test_func" assert item.funcargs['other'] == 42 @@ -58,9 +58,9 @@ class TestFuncargs: pass """) item1, item2 = testdir.genitems([modcol]) - item1.setupargs() + item1._setupfuncargs() assert item1.funcargs['something'] == "test_method" - item2.setupargs() + item2._setupfuncargs() assert item2.funcargs['something'] == "test_func" class TestRequest: