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

fix: fix log level level with pytest #444

Merged
merged 2 commits into from
Feb 7, 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
8 changes: 3 additions & 5 deletions src/pykiso/pytest_plugin/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,26 @@ def pytest_sessionstart(session: Session):
log_level=logging.getLevelName(pytest_logger.log_cli_level),
report_type="text",
# display internal logs at least -vv is provided
verbose=(session.config.getoption("verbose") > 1),
verbose=(session.config.getoption("verbose") > 2),
)
root_logger = logging.getLogger()

# get all handlers that were configured by pykiso to retrieve their level
stream_handler = next(
(
hdlr
for hdlr in root_logger.handlers
if isinstance(hdlr, logging.StreamHandler)
if type(hdlr) == logging.StreamHandler
),
None,
)
file_handler = next(
(
hdlr
for hdlr in root_logger.handlers
if isinstance(hdlr, logging.FileHandler)
if type(hdlr) == logging.FileHandler
),
None,
)

if (
pytest_logger.log_cli_handler.level != logging.NOTSET
and stream_handler is not None
Expand Down
Loading