diff options
author | Ran Benita <ran@unusedvar.com> | 2021-01-01 12:08:12 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2021-01-24 14:08:39 +0200 |
commit | 2b14edb108f32c49c15b5e0c0ef4d27880b09e0f (patch) | |
tree | f0a379cc69cd3c629f026d646cbedb6aa0af7e19 /src | |
parent | ceb4d6f6d595532be599e6382b571f3b4f614df9 (diff) | |
download | pytest-2b14edb108f32c49c15b5e0c0ef4d27880b09e0f.tar.gz |
runner: express SetupState.teardown_all() in terms of teardown_exact() and remove it
Makes it easier to understand with fewer methods.
Diffstat (limited to 'src')
-rw-r--r-- | src/_pytest/runner.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 5d35f520a..525aafc76 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -105,7 +105,7 @@ def pytest_sessionstart(session: "Session") -> None: def pytest_sessionfinish(session: "Session") -> None: - session._setupstate.teardown_all() + session._setupstate.teardown_exact(None) def pytest_runtest_protocol(item: Item, nextitem: Optional[Item]) -> bool: @@ -177,7 +177,7 @@ def pytest_runtest_call(item: Item) -> None: def pytest_runtest_teardown(item: Item, nextitem: Optional[Item]) -> None: _update_current_test_var(item, "teardown") - item.session._setupstate.teardown_exact(item, nextitem) + item.session._setupstate.teardown_exact(nextitem) _update_current_test_var(item, None) @@ -455,7 +455,7 @@ class SetupState: for colitem in self._finalizers: assert colitem in self.stack - def teardown_exact(self, item: Item, nextitem: Optional[Item]) -> None: + def teardown_exact(self, nextitem: Optional[Item]) -> None: needed_collectors = nextitem and nextitem.listchain() or [] exc = None while self.stack: @@ -470,11 +470,8 @@ class SetupState: exc = e if exc: raise exc - - def teardown_all(self) -> None: - while self.stack: - self._pop_and_teardown() - assert not self._finalizers + if nextitem is None: + assert not self._finalizers def collect_one_node(collector: Collector) -> CollectReport: |