Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Flush logger hanlders at exit #298

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading