runner: inline a couple of SetupState methods
Code is clearer this way.
This commit is contained in:
parent
5f4e55fb6d
commit
ceb4d6f6d5
|
@ -438,9 +438,6 @@ class SetupState:
|
||||||
|
|
||||||
def _pop_and_teardown(self) -> None:
|
def _pop_and_teardown(self) -> None:
|
||||||
colitem = self.stack.pop()
|
colitem = self.stack.pop()
|
||||||
self._teardown_with_finalization(colitem)
|
|
||||||
|
|
||||||
def _callfinalizers(self, colitem: Node) -> None:
|
|
||||||
finalizers = self._finalizers.pop(colitem, None)
|
finalizers = self._finalizers.pop(colitem, None)
|
||||||
exc = None
|
exc = None
|
||||||
while finalizers:
|
while finalizers:
|
||||||
|
@ -454,9 +451,6 @@ class SetupState:
|
||||||
exc = e
|
exc = e
|
||||||
if exc:
|
if exc:
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
def _teardown_with_finalization(self, colitem: Node) -> None:
|
|
||||||
self._callfinalizers(colitem)
|
|
||||||
colitem.teardown()
|
colitem.teardown()
|
||||||
for colitem in self._finalizers:
|
for colitem in self._finalizers:
|
||||||
assert colitem in self.stack
|
assert colitem in self.stack
|
||||||
|
|
|
@ -64,11 +64,12 @@ class TestSetupState:
|
||||||
|
|
||||||
item = pytester.getitem("def test_func(): pass")
|
item = pytester.getitem("def test_func(): pass")
|
||||||
ss = runner.SetupState()
|
ss = runner.SetupState()
|
||||||
|
ss.prepare(item)
|
||||||
ss.addfinalizer(fin1, item)
|
ss.addfinalizer(fin1, item)
|
||||||
ss.addfinalizer(fin2, item)
|
ss.addfinalizer(fin2, item)
|
||||||
ss.addfinalizer(fin3, item)
|
ss.addfinalizer(fin3, item)
|
||||||
with pytest.raises(Exception) as err:
|
with pytest.raises(Exception) as err:
|
||||||
ss._callfinalizers(item)
|
ss.teardown_exact(item, None)
|
||||||
assert err.value.args == ("oops",)
|
assert err.value.args == ("oops",)
|
||||||
assert r == ["fin3", "fin1"]
|
assert r == ["fin3", "fin1"]
|
||||||
|
|
||||||
|
@ -83,10 +84,11 @@ class TestSetupState:
|
||||||
|
|
||||||
item = pytester.getitem("def test_func(): pass")
|
item = pytester.getitem("def test_func(): pass")
|
||||||
ss = runner.SetupState()
|
ss = runner.SetupState()
|
||||||
|
ss.prepare(item)
|
||||||
ss.addfinalizer(fin1, item)
|
ss.addfinalizer(fin1, item)
|
||||||
ss.addfinalizer(fin2, item)
|
ss.addfinalizer(fin2, item)
|
||||||
with pytest.raises(Exception) as err:
|
with pytest.raises(Exception) as err:
|
||||||
ss._callfinalizers(item)
|
ss.teardown_exact(item, None)
|
||||||
assert err.value.args == ("oops2",)
|
assert err.value.args == ("oops2",)
|
||||||
|
|
||||||
def test_teardown_multiple_scopes_one_fails(self, pytester: Pytester) -> None:
|
def test_teardown_multiple_scopes_one_fails(self, pytester: Pytester) -> None:
|
||||||
|
|
Loading…
Reference in New Issue