allow re-running of a test item (as exercised by the

pytest-rerunfailures plugins) by re-initializing and removing
request/funcargs information in runtestprotocol() - which is a slightly
odd place to add funcarg-related functionality but it allows all
pytest_runtest_setup/teardown hooks to properly see a valid
request/funcarg content on test items.
This commit is contained in:
holger krekel
2013-04-22 10:35:48 +02:00
parent cf7cae0780
commit b2cb93e06d
7 changed files with 57 additions and 8 deletions

View File

@@ -917,20 +917,25 @@ class Function(FunctionMixin, pytest.Item, FuncargnamesCompatAttr):
self.cls,
funcargs=not isyield)
self.fixturenames = fi.names_closure
if isyield:
assert not callspec, (
if callspec is not None:
self.callspec = callspec
self._initrequest()
def _initrequest(self):
if self._isyieldedfunction():
assert not hasattr(self, "callspec"), (
"yielded functions (deprecated) cannot have funcargs")
self.funcargs = {}
else:
if callspec is not None:
self.callspec = callspec
self.funcargs = callspec.funcargs or {}
if hasattr(self, "callspec"):
callspec = self.callspec
self.funcargs = callspec.funcargs.copy()
self._genid = callspec.id
if hasattr(callspec, "param"):
self.param = callspec.param
else:
self.funcargs = {}
self._request = req = FixtureRequest(self)
self._request = FixtureRequest(self)
@property
def function(self):