diff options
author | Ran Benita <ran@unusedvar.com> | 2021-01-01 14:13:39 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2021-01-24 14:08:39 +0200 |
commit | 960ebae943927805091153bfe17677c5f3734198 (patch) | |
tree | ce779690726fc3fb47a97d5a53fe5d7d20fb785a /src | |
parent | 6db082a4486923637b4f427c95ab379d81b78528 (diff) | |
download | pytest-960ebae943927805091153bfe17677c5f3734198.tar.gz |
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.
Diffstat (limited to 'src')
-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 [] |