Skip to content

Commit

Permalink
Remove unnecessary checks from SetupState
Browse files Browse the repository at this point in the history
Since 4622c28, _finalizers cannot
contain Nones or tuples, so these checks are not longer needed.
  • Loading branch information
bluetech committed Jul 16, 2019
1 parent cb07f1e commit 1b8dd9b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ def __init__(self):
self._finalizers = {}

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

def _teardown_with_finalization(self, colitem):
self._callfinalizers(colitem)
if hasattr(colitem, "teardown"):
colitem.teardown()
colitem.teardown()
for colitem in self._finalizers:
assert (
colitem is None or colitem in self.stack or isinstance(colitem, tuple)
)
assert colitem in self.stack

def teardown_all(self):
while self.stack:
Expand Down

0 comments on commit 1b8dd9b

Please sign in to comment.