handle and reraise subrequest finalizer exceptions
This commit is contained in:
@@ -733,10 +733,16 @@ class FixtureDef:
|
||||
self._finalizer.append(finalizer)
|
||||
|
||||
def finish(self):
|
||||
exceptions = []
|
||||
try:
|
||||
while self._finalizer:
|
||||
func = self._finalizer.pop()
|
||||
func()
|
||||
try:
|
||||
func = self._finalizer.pop()
|
||||
func()
|
||||
except:
|
||||
exceptions.append(sys.exc_info())
|
||||
if exceptions:
|
||||
py.builtin._reraise(*exceptions[0])
|
||||
finally:
|
||||
ihook = self._fixturemanager.session.ihook
|
||||
ihook.pytest_fixture_post_finalizer(fixturedef=self)
|
||||
|
||||
Reference in New Issue
Block a user