Remove unnecessary checks from SetupState

Since 4622c28ffd, _finalizers cannot
contain Nones or tuples, so these checks are not longer needed.
This commit is contained in:
Ran Benita 2019-07-15 22:09:01 +03:00
parent 7d1c697c30
commit 0b532fda76
1 changed files with 3 additions and 9 deletions

View File

@ -278,10 +278,7 @@ class SetupState:
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 :/
@ -309,12 +306,9 @@ class SetupState:
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: