From 3f68028c08de596f462827b17e425d21f7d02f41 Mon Sep 17 00:00:00 2001 From: adiholden Date: Wed, 18 Dec 2024 18:03:37 +0200 Subject: [PATCH] fix(pytest): call stop for all instances even if stop raise exception (#4339) Signed-off-by: adi_holden --- tests/dragonfly/instance.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/dragonfly/instance.py b/tests/dragonfly/instance.py index 8feaeea0d..90afa6db8 100644 --- a/tests/dragonfly/instance.py +++ b/tests/dragonfly/instance.py @@ -453,9 +453,19 @@ class DflyInstanceFactory: async def stop_all(self): """Stop all launched instances.""" + exceptions = [] # To collect exceptions for instance in self.instances: await instance.close_clients() - instance.stop() + try: + instance.stop() + except Exception as e: + exceptions.append(e) # Collect the exception + if exceptions: + first_exception = exceptions[0] + raise Exception( + f"One or more errors occurred while stopping instances. " + f"First exception: {first_exception}" + ) from first_exception def __repr__(self) -> str: return f"Factory({self.args})"