minimal changes to expose fillfuncargs
--HG-- branch : trunk
This commit is contained in:
parent
f2b1eb5bba
commit
e79f4d298c
|
@ -79,6 +79,7 @@ initpkg(__name__,
|
||||||
'test.fail' : ('./test/outcome.py', 'fail'),
|
'test.fail' : ('./test/outcome.py', 'fail'),
|
||||||
'test.exit' : ('./test/outcome.py', 'exit'),
|
'test.exit' : ('./test/outcome.py', 'exit'),
|
||||||
'test.pdb' : ('./test/custompdb.py', 'set_trace'),
|
'test.pdb' : ('./test/custompdb.py', 'set_trace'),
|
||||||
|
'test.fillfuncargs' : ('./test/funcargs.py', 'fillfuncargs'),
|
||||||
|
|
||||||
# configuration/initialization related test api
|
# configuration/initialization related test api
|
||||||
'test.config' : ('./test/config.py', 'config_per_process'),
|
'test.config' : ('./test/config.py', 'config_per_process'),
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FuncargRequest:
|
||||||
def _fillfuncargs(self):
|
def _fillfuncargs(self):
|
||||||
argnames = getfuncargnames(self.function)
|
argnames = getfuncargnames(self.function)
|
||||||
if argnames:
|
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:
|
for argname in argnames:
|
||||||
if argname not in self._pyfuncitem.funcargs:
|
if argname not in self._pyfuncitem.funcargs:
|
||||||
self._pyfuncitem.funcargs[argname] = self.getfuncargvalue(argname)
|
self._pyfuncitem.funcargs[argname] = self.getfuncargvalue(argname)
|
||||||
|
|
|
@ -79,6 +79,17 @@ class TestFillFuncArgs:
|
||||||
"*1 passed*"
|
"*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.fillfuncargs(item)
|
||||||
|
assert len(item.funcargs) == 1
|
||||||
|
|
||||||
class TestRequest:
|
class TestRequest:
|
||||||
def test_request_attributes(self, testdir):
|
def test_request_attributes(self, testdir):
|
||||||
item = testdir.getitem("""
|
item = testdir.getitem("""
|
||||||
|
|
Loading…
Reference in New Issue