runner: collapse exception handling in SetupState.teardown_exact()

This is equivalent but simpler.
This commit is contained in:
Ran Benita 2021-01-01 13:06:50 +02:00
parent bb3d43c9a6
commit 0d4121d24b
1 changed files with 14 additions and 23 deletions

View File

@ -443,29 +443,20 @@ class SetupState:
while self.stack:
if self.stack == needed_collectors[: len(self.stack)]:
break
try:
colitem = self.stack.pop()
finalizers = self._finalizers.pop(colitem)
finalizers.insert(0, colitem.teardown)
inner_exc = None
while finalizers:
fin = finalizers.pop()
try:
fin()
except TEST_OUTCOME as e:
# XXX Only first exception will be seen by user,
# ideally all should be reported.
if inner_exc is None:
inner_exc = e
for colitem in self._finalizers:
assert colitem in self.stack
if inner_exc:
raise inner_exc
except TEST_OUTCOME as e:
# XXX Only first exception will be seen by user,
# ideally all should be reported.
if exc is None:
exc = e
colitem = self.stack.pop()
finalizers = self._finalizers.pop(colitem)
finalizers.insert(0, colitem.teardown)
while finalizers:
fin = finalizers.pop()
try:
fin()
except TEST_OUTCOME as e:
# XXX Only first exception will be seen by user,
# ideally all should be reported.
if exc is None:
exc = e
for colitem in self._finalizers:
assert colitem in self.stack
if exc:
raise exc
if nextitem is None: