Skip to content

Commit 9059722

Browse files
authored
Merge pull request #4829 from nicoddemus/yield-tests-dead-code
Remove dead-code related to yield tests
2 parents 936f725 + b7ae7a6 commit 9059722

File tree

3 files changed

+11
-33
lines changed

3 files changed

+11
-33
lines changed

changelog/4829.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Some left-over internal code related to ``yield`` tests has been removed.

src/_pytest/debugging.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,12 @@ def _test_pytest_function(pyfuncitem):
209209
_pdb = pytestPDB._init_pdb()
210210
testfunction = pyfuncitem.obj
211211
pyfuncitem.obj = _pdb.runcall
212-
if pyfuncitem._isyieldedfunction():
213-
arg_list = list(pyfuncitem._args)
214-
arg_list.insert(0, testfunction)
215-
pyfuncitem._args = tuple(arg_list)
216-
else:
217-
if "func" in pyfuncitem._fixtureinfo.argnames:
218-
raise ValueError("--trace can't be used with a fixture named func!")
219-
pyfuncitem.funcargs["func"] = testfunction
220-
new_list = list(pyfuncitem._fixtureinfo.argnames)
221-
new_list.append("func")
222-
pyfuncitem._fixtureinfo.argnames = tuple(new_list)
212+
if "func" in pyfuncitem._fixtureinfo.argnames: # noqa
213+
raise ValueError("--trace can't be used with a fixture named func!")
214+
pyfuncitem.funcargs["func"] = testfunction
215+
new_list = list(pyfuncitem._fixtureinfo.argnames)
216+
new_list.append("func")
217+
pyfuncitem._fixtureinfo.argnames = tuple(new_list)
223218

224219

225220
def _enter_pdb(node, excinfo, rep):

src/_pytest/python.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,9 @@ def pytest_configure(config):
156156
@hookimpl(trylast=True)
157157
def pytest_pyfunc_call(pyfuncitem):
158158
testfunction = pyfuncitem.obj
159-
if pyfuncitem._isyieldedfunction():
160-
testfunction(*pyfuncitem._args)
161-
else:
162-
funcargs = pyfuncitem.funcargs
163-
testargs = {}
164-
for arg in pyfuncitem._fixtureinfo.argnames:
165-
testargs[arg] = funcargs[arg]
166-
testfunction(**testargs)
159+
funcargs = pyfuncitem.funcargs
160+
testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}
161+
testfunction(**testargs)
167162
return True
168163

169164

@@ -1405,7 +1400,7 @@ def __init__(
14051400

14061401
if fixtureinfo is None:
14071402
fixtureinfo = self.session._fixturemanager.getfixtureinfo(
1408-
self, self.obj, self.cls, funcargs=not self._isyieldedfunction()
1403+
self, self.obj, self.cls, funcargs=True
14091404
)
14101405
self._fixtureinfo = fixtureinfo
14111406
self.fixturenames = fixtureinfo.names_closure
@@ -1419,16 +1414,6 @@ def __init__(
14191414

14201415
def _initrequest(self):
14211416
self.funcargs = {}
1422-
if self._isyieldedfunction():
1423-
assert not hasattr(
1424-
self, "callspec"
1425-
), "yielded functions (deprecated) cannot have funcargs"
1426-
else:
1427-
if hasattr(self, "callspec"):
1428-
callspec = self.callspec
1429-
assert not callspec.funcargs
1430-
if hasattr(callspec, "param"):
1431-
self.param = callspec.param
14321417
self._request = fixtures.FixtureRequest(self)
14331418

14341419
@property
@@ -1448,9 +1433,6 @@ def _pyfuncitem(self):
14481433
"(compatonly) for code expecting pytest-2.2 style request objects"
14491434
return self
14501435

1451-
def _isyieldedfunction(self):
1452-
return getattr(self, "_args", None) is not None
1453-
14541436
def runtest(self):
14551437
""" execute the underlying test function. """
14561438
self.ihook.pytest_pyfunc_call(pyfuncitem=self)

0 commit comments

Comments
 (0)