We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13f305d commit 2f3ef3cCopy full SHA for 2f3ef3c
cli_test_helpers/decorators.py
@@ -33,7 +33,14 @@ def __enter__(self):
33
34
def __exit__(self, exc_type, exc_val, exc_tb):
35
"""Restore logging handlers after exiting the context."""
36
+ # Close and remove any handlers that were added during the context
37
if hasattr(self, "_old_handlers"):
38
+ for handler in logging.root.handlers[:]:
39
+ # Close handlers that weren't in the original list
40
+ if handler not in self._old_handlers:
41
+ handler.close()
42
+ logging.root.handlers.remove(handler)
43
+ # Restore the original handlers
44
logging.root.handlers[:] = self._old_handlers
45
# Call parent __exit__ if it exists (for cooperative inheritance)
46
if hasattr(super(), "__exit__"):
0 commit comments