Skip to content

Commit

Permalink
chore: Flush logger hanlders at exit (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Dec 4, 2024
1 parent f230647 commit 95e2296
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/conftest.py
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)

0 comments on commit 95e2296

Please sign in to comment.