From 54844f3c6988e08adaa17a275ca6a949654813c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Mon, 25 Nov 2024 22:41:47 -0600 Subject: [PATCH] chore: Flush logger hanlders at exit --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 4ba4b219..efc20927 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1,16 @@ """Test Configuration.""" + + +def pytest_sessionfinish(session, exitstatus): + """Session Finish.""" + import logging + + loggers: list[logging.Logger] = [ + logging.getLogger(), + *list(logging.Logger.manager.loggerDict.values()), + ] + + for logger in loggers: + handlers = getattr(logger, "handlers", []) + for handler in handlers: + logger.removeHandler(handler)