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:
parent
7d1c697c30
commit
0b532fda76
|
@ -278,10 +278,7 @@ class SetupState:
|
||||||
self._finalizers = {}
|
self._finalizers = {}
|
||||||
|
|
||||||
def addfinalizer(self, finalizer, colitem):
|
def addfinalizer(self, finalizer, colitem):
|
||||||
""" attach a finalizer to the given 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().
|
|
||||||
"""
|
|
||||||
assert colitem and not isinstance(colitem, tuple)
|
assert colitem and not isinstance(colitem, tuple)
|
||||||
assert callable(finalizer)
|
assert callable(finalizer)
|
||||||
# assert colitem in self.stack # some unit tests don't setup stack :/
|
# assert colitem in self.stack # some unit tests don't setup stack :/
|
||||||
|
@ -309,12 +306,9 @@ class SetupState:
|
||||||
|
|
||||||
def _teardown_with_finalization(self, colitem):
|
def _teardown_with_finalization(self, colitem):
|
||||||
self._callfinalizers(colitem)
|
self._callfinalizers(colitem)
|
||||||
if hasattr(colitem, "teardown"):
|
colitem.teardown()
|
||||||
colitem.teardown()
|
|
||||||
for colitem in self._finalizers:
|
for colitem in self._finalizers:
|
||||||
assert (
|
assert colitem in self.stack
|
||||||
colitem is None or colitem in self.stack or isinstance(colitem, tuple)
|
|
||||||
)
|
|
||||||
|
|
||||||
def teardown_all(self):
|
def teardown_all(self):
|
||||||
while self.stack:
|
while self.stack:
|
||||||
|
|
Loading…
Reference in New Issue