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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user