Skip to content

Commit 7b77fc0

Browse files
authored
Merge pull request #7368 from bluetech/teardown-in-setup
runner: don't try to teardown previous items from pytest_runtest_setup
2 parents 4f4c263 + bb878a2 commit 7b77fc0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/_pytest/runner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,15 @@ def _teardown_towards(self, needed_collectors) -> None:
409409
raise exc
410410

411411
def prepare(self, colitem) -> None:
412-
""" setup objects along the collector chain to the test-method
413-
and teardown previously setup objects."""
414-
needed_collectors = colitem.listchain()
415-
self._teardown_towards(needed_collectors)
412+
"""Setup objects along the collector chain to the test-method."""
416413

417414
# check if the last collection node has raised an error
418415
for col in self.stack:
419416
if hasattr(col, "_prepare_exc"):
420417
exc = col._prepare_exc # type: ignore[attr-defined] # noqa: F821
421418
raise exc
419+
420+
needed_collectors = colitem.listchain()
422421
for col in needed_collectors[len(self.stack) :]:
423422
self.stack.append(col)
424423
try:

0 commit comments

Comments
 (0)