From e3b862adca22f1d0b06b854275d6b7b64571b64d Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Mon, 4 Feb 2019 20:19:07 +0100 Subject: [PATCH] Remove unneeded 2nd _setup_cli_logging call During the review of #4204 it was not noticed that _setup_cli_logging was already called in the collection phase (pytest_collection). Now _setup_cli_Logging is called in two hooks: pytest_collection and pytest_sessionstart. It only makes sense to call _setup_cli_logging once (in the first called hook of the logging plugin). --- src/_pytest/logging.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 0c47b8b5153..97528982823 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -430,10 +430,6 @@ def _log_cli_enabled(self): @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_collection(self): - # This has to be called before the first log message is logged, - # so we can access the terminal reporter plugin. - self._setup_cli_logging() - with self.live_logs_context(): if self.log_cli_handler: self.log_cli_handler.set_when("collection") @@ -513,6 +509,8 @@ def pytest_sessionfinish(self): @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_sessionstart(self): + # This has to be called before the first log message is logged, + # so we can access the terminal reporter plugin. self._setup_cli_logging() with self.live_logs_context(): if self.log_cli_handler: