diff --git a/py/__init__.py b/py/__init__.py index b89db91d1..8d072a666 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -89,6 +89,7 @@ initpkg(__name__, 'test.collect.Instance' : ('./test/pycollect.py', 'Instance'), 'test.collect.Generator' : ('./test/pycollect.py', 'Generator'), 'test.collect.Function' : ('./test/pycollect.py', 'Function'), + 'test.collect._fillfuncargs' : ('./test/funcargs.py', 'fillfuncargs'), # thread related API (still in early design phase) '_thread.WorkerPool' : ('./thread/pool.py', 'WorkerPool'), diff --git a/py/test/funcargs.py b/py/test/funcargs.py index 72d37265c..22ba09807 100644 --- a/py/test/funcargs.py +++ b/py/test/funcargs.py @@ -95,7 +95,7 @@ class FuncargRequest: def _fillfuncargs(self): argnames = getfuncargnames(self.function) if argnames: - assert not self._pyfuncitem._args, "yielded functions cannot have funcargs" + assert not getattr(self._pyfuncitem, '_args', None), "yielded functions cannot have funcargs" for argname in argnames: if argname not in self._pyfuncitem.funcargs: self._pyfuncitem.funcargs[argname] = self.getfuncargvalue(argname) diff --git a/py/test/testing/test_funcargs.py b/py/test/testing/test_funcargs.py index 566ade322..bb7e832ae 100644 --- a/py/test/testing/test_funcargs.py +++ b/py/test/testing/test_funcargs.py @@ -79,6 +79,17 @@ class TestFillFuncArgs: "*1 passed*" ]) + def test_fillfuncargs_exposed(self, testdir): + item = testdir.getitem("def test_func(some, other=42): pass") + class Provider: + def pytest_funcarg__some(self, request): + return request.function.__name__ + item.config.pluginmanager.register(Provider()) + if hasattr(item, '_args'): + del item._args + py.test.collect._fillfuncargs(item) + assert len(item.funcargs) == 1 + class TestRequest: def test_request_attributes(self, testdir): item = testdir.getitem("""