Skip to content

Commit

Permalink
squash: fix logging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Feb 20, 2024
1 parent cc876f0 commit 4fb6340
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/unit/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import _pytest.capture
import _pytest.logging
import click
import pytest

import tmt.utils
from tmt.log import (
DebugLevelFilter,
Logger,
Expand All @@ -30,7 +30,8 @@ def _exercise_logger(
reset: bool = True) -> None:
labels = labels or []

prefix = render_labels(labels) + indent_by + ' ' if labels else indent_by
prefix = tmt.utils.remove_color(render_labels(labels)) + indent_by + ' ' \
if labels else indent_by

if reset:
caplog.clear()
Expand All @@ -50,7 +51,7 @@ def _exercise_logger(
details_key='this is printed',
details_logger_labels=labels,
levelno=logging.INFO)
assert captured.out == f'{prefix}this is printed\n'
assert tmt.utils.remove_color(captured.out) == f'{prefix}this is printed\n'
assert_log(
caplog,
message=f'{prefix}this is a debug message',
Expand All @@ -71,14 +72,14 @@ def _exercise_logger(
levelno=logging.INFO)
assert_log(
caplog,
message=f'{prefix}{click.style("warn", fg="yellow")}: this is a warning',
message=f'{prefix}warn: this is a warning',
details_key='warn',
details_value='this is a warning',
details_logger_labels=labels,
levelno=logging.WARN)
assert_log(
caplog,
message=f'{prefix}{click.style("fail", fg="red")}: this is a failure',
message=f'{prefix}fail: this is a failure',
details_key='fail',
details_value='this is a failure',
details_logger_labels=labels,
Expand Down

0 comments on commit 4fb6340

Please sign in to comment.