Skip to content

Commit 2c6c3b8

Browse files
Roman Kuznecovcidlik
Roman Kuznecov
authored andcommitted
Use add_color_level() conditionally
According to [1] add_color_level() is a method of ColoredLevelFormatter only. [1] https://github.com/pytest-dev/pytest/blob/main/src/_pytest/logging.py#L104 Change-Id: Iaa67c613b196b9cbbbc930d547edaa784d545130
1 parent c609d2d commit 2c6c3b8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

labgrid/pytestplugin/hooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def set_cli_log_level(level):
4343

4444

4545
def configure_pytest_logging(config, plugin):
46-
plugin.log_cli_handler.formatter.add_color_level(logging.CONSOLE, "blue")
46+
if hasattr(plugin.log_cli_handler.formatter, "add_color_level"):
47+
plugin.log_cli_handler.formatter.add_color_level(logging.CONSOLE, "blue")
4748
plugin.log_cli_handler.setFormatter(StepFormatter(
4849
color=config.option.lg_colored_steps,
4950
parent=plugin.log_cli_handler.formatter,

0 commit comments

Comments
 (0)