Skip to content

Commit ad7d63d

Browse files
committed
Rename _stream_logs_enabled to _log_cli_enabled and remove _stream_logs
1 parent 0b71255 commit ad7d63d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_pytest/logging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,9 @@ def __init__(self, config):
336336
create a single one for the entire test session here.
337337
"""
338338
self._config = config
339-
self._stream_logs = None
340339

341340
# enable verbose output automatically if live logging is enabled
342-
if self._stream_logs_enabled() and not config.getoption('verbose'):
341+
if self._log_cli_enabled() and not config.getoption('verbose'):
343342
# sanity check: terminal reporter should not have been loaded at this point
344343
assert self._config.pluginmanager.get_plugin('terminalreporter') is None
345344
config.option.verbose = 1
@@ -365,11 +364,12 @@ def __init__(self, config):
365364
# initialized during pytest_runtestloop
366365
self.log_cli_handler = None
367366

368-
def _stream_logs_enabled(self):
369-
if self._stream_logs is None:
370-
self._stream_logs = self._config.getoption('--log-cli-level') is not None or \
371-
self._config.getini('log_cli')
372-
return self._stream_logs
367+
def _log_cli_enabled(self):
368+
"""Return True if log_cli should be considered enabled, either explicitly
369+
or because --log-cli-level was given in the command-line.
370+
"""
371+
return self._config.getoption('--log-cli-level') is not None or \
372+
self._config.getini('log_cli')
373373

374374
@contextmanager
375375
def _runtest_for(self, item, when):
@@ -445,7 +445,7 @@ def _setup_cli_logging(self):
445445
This must be done right before starting the loop so we can access the terminal reporter plugin.
446446
"""
447447
terminal_reporter = self._config.pluginmanager.get_plugin('terminalreporter')
448-
if self._stream_logs_enabled() and terminal_reporter is not None:
448+
if self._log_cli_enabled() and terminal_reporter is not None:
449449
capture_manager = self._config.pluginmanager.get_plugin('capturemanager')
450450
log_cli_handler = _LiveLoggingStreamHandler(terminal_reporter, capture_manager)
451451
log_cli_format = get_option_ini(self._config, 'log_cli_format', 'log_format')

0 commit comments

Comments
 (0)