Skip to content

Commit 0b532fd

Browse files
committed
Remove unnecessary checks from SetupState
Since 4622c28, _finalizers cannot contain Nones or tuples, so these checks are not longer needed.
1 parent 7d1c697 commit 0b532fd

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/_pytest/runner.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,7 @@ def __init__(self):
278278
self._finalizers = {}
279279

280280
def addfinalizer(self, finalizer, colitem):
281-
""" attach a finalizer to the given colitem.
282-
if colitem is None, this will add a finalizer that
283-
is called at the end of teardown_all().
284-
"""
281+
""" attach a finalizer to the given colitem. """
285282
assert colitem and not isinstance(colitem, tuple)
286283
assert callable(finalizer)
287284
# assert colitem in self.stack # some unit tests don't setup stack :/
@@ -309,12 +306,9 @@ def _callfinalizers(self, colitem):
309306

310307
def _teardown_with_finalization(self, colitem):
311308
self._callfinalizers(colitem)
312-
if hasattr(colitem, "teardown"):
313-
colitem.teardown()
309+
colitem.teardown()
314310
for colitem in self._finalizers:
315-
assert (
316-
colitem is None or colitem in self.stack or isinstance(colitem, tuple)
317-
)
311+
assert colitem in self.stack
318312

319313
def teardown_all(self):
320314
while self.stack:

0 commit comments

Comments
 (0)