runner: ensure item.teardown() is called even if a finalizer raised
If one finalizer fails, all of the subsequent finalizers still run, so the `teardown()` method should behave the same.
This commit is contained in:
parent
14d71b2c22
commit
bb3d43c9a6
|
@ -446,6 +446,7 @@ class SetupState:
|
||||||
try:
|
try:
|
||||||
colitem = self.stack.pop()
|
colitem = self.stack.pop()
|
||||||
finalizers = self._finalizers.pop(colitem)
|
finalizers = self._finalizers.pop(colitem)
|
||||||
|
finalizers.insert(0, colitem.teardown)
|
||||||
inner_exc = None
|
inner_exc = None
|
||||||
while finalizers:
|
while finalizers:
|
||||||
fin = finalizers.pop()
|
fin = finalizers.pop()
|
||||||
|
@ -456,11 +457,10 @@ class SetupState:
|
||||||
# ideally all should be reported.
|
# ideally all should be reported.
|
||||||
if inner_exc is None:
|
if inner_exc is None:
|
||||||
inner_exc = e
|
inner_exc = e
|
||||||
if inner_exc:
|
|
||||||
raise inner_exc
|
|
||||||
colitem.teardown()
|
|
||||||
for colitem in self._finalizers:
|
for colitem in self._finalizers:
|
||||||
assert colitem in self.stack
|
assert colitem in self.stack
|
||||||
|
if inner_exc:
|
||||||
|
raise inner_exc
|
||||||
except TEST_OUTCOME as e:
|
except TEST_OUTCOME as e:
|
||||||
# XXX Only first exception will be seen by user,
|
# XXX Only first exception will be seen by user,
|
||||||
# ideally all should be reported.
|
# ideally all should be reported.
|
||||||
|
|
Loading…
Reference in New Issue