runner: enable a commented assertion in SetupState.addfinalizer

The assertion ensures that when `addfinalizer(finalizer, node)` is
called, the node is in the stack. This then would ensure that the
finalization is actually properly executed properly during the node's
teardown. Anything else indicates something is wrong.

Previous commits fixed all of the tests which previously failed this, so
can be reenabeld now.
This commit is contained in:
Ran Benita 2021-01-01 14:13:39 +02:00
parent 6db082a448
commit 960ebae943
1 changed files with 2 additions and 2 deletions

View File

@ -434,8 +434,8 @@ class SetupState:
"""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 :/
self._finalizers.setdefault(colitem, []).append(finalizer)
assert colitem in self.stack, (colitem, self.stack)
self._finalizers[colitem].append(finalizer)
def teardown_exact(self, nextitem: Optional[Item]) -> None:
needed_collectors = nextitem and nextitem.listchain() or []