From 29a7b5e064d57f510dba92861e7977eb4a7cbb22 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 20 Jan 2018 14:19:45 -0200 Subject: [PATCH] Initialize log_cli_handler to None during LoggingPlugin init Some of testdir's functionality bypasses pytest_runtestloop so this attribute needs to be set early --- _pytest/logging.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_pytest/logging.py b/_pytest/logging.py index 254740188..8086ea386 100644 --- a/_pytest/logging.py +++ b/_pytest/logging.py @@ -296,6 +296,9 @@ class LoggingPlugin(object): else: self.log_file_handler = None + # initialized during pytest_runtestloop + self.log_cli_handler = None + @contextmanager def _runtest_for(self, item, when): """Implements the internals of pytest_runtest_xxx() hook.""" @@ -363,7 +366,6 @@ class LoggingPlugin(object): self.log_cli_handler = log_cli_handler self.live_logs_context = catching_logs(log_cli_handler, formatter=log_cli_formatter, level=log_cli_level) else: - self.log_cli_handler = None self.live_logs_context = _dummy_context_manager()