Skip to content

Commit 38245ca

Browse files
committed
Guard reset_instance try..except
1 parent af44641 commit 38245ca

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mreg_api/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ def __call__(cls: type[Any], *args: Any, **kwargs: Any):
9090

9191
def reset_instance(self) -> None:
9292
"""Reset the singleton instance (useful for testing)."""
93-
del self._instances[self]
93+
try:
94+
del self._instances[self]
95+
except KeyError:
96+
pass
9497

9598

9699
class RequestRecord(NamedTuple):

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def reset_instance_after_test() -> Generator[None, None, None]:
1919
# FIXME: Can we force the destructor to be called?
2020
# MregClient()._reset_contextvars() # pyright: ignore[reportPrivateUsage]
2121
MregClient.reset_instance()
22-
except KeyError:
22+
except Exception:
2323
pass
2424

2525

0 commit comments

Comments
 (0)