diff options
-rw-r--r-- | src/_pytest/runner.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 3aa0a6c4b..9759441bd 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -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 [] |