-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Flush logger hanlders at exit (#298)
- Loading branch information
1 parent
f230647
commit 95e2296
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
"""Test Configuration.""" | ||
|
||
from __future__ import annotations | ||
|
||
import typing as t | ||
|
||
if t.TYPE_CHECKING: | ||
import pytest | ||
|
||
|
||
def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None: # noqa: ARG001 | ||
"""Session Finish.""" | ||
import logging | ||
|
||
loggers: list[logging.Logger] = [ | ||
logging.getLogger(), | ||
*list(logging.Logger.manager.loggerDict.values()), # type: ignore[list-item] | ||
] | ||
|
||
for logger in loggers: | ||
handlers = getattr(logger, "handlers", []) | ||
for handler in handlers: | ||
logger.removeHandler(handler) |