Skip to content

Commit

Permalink
Fix verbosity bug in --collect-only
Browse files Browse the repository at this point in the history
  • Loading branch information
twmr committed Jun 4, 2019
1 parent 6a6b6d8 commit e865b27
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelog/5383.bugfix.rst
@@ -0,0 +1,2 @@
``-q`` has again an impact on the style of the collected items
(``--collect-only``) when ``--log-cli-level`` is used.
8 changes: 4 additions & 4 deletions src/_pytest/logging.py
Expand Up @@ -409,10 +409,6 @@ def __init__(self, config):
"""
self._config = config

# enable verbose output automatically if live logging is enabled
if self._log_cli_enabled() and config.getoption("verbose") < 1:
config.option.verbose = 1

self.print_logs = get_option_ini(config, "log_print")
self.formatter = self._create_formatter(
get_option_ini(config, "log_format"),
Expand Down Expand Up @@ -628,6 +624,10 @@ def pytest_sessionstart(self):
@pytest.hookimpl(hookwrapper=True)
def pytest_runtestloop(self, session):
"""Runs all collected test items."""
if self._log_cli_enabled() and self._config.getoption("verbose") < 1:
# setting verbose flag is needed to avoid messy test progress output
self._config.option.verbose = 1

with self.live_logs_context():
if self.log_file_handler is not None:
with catching_logs(self.log_file_handler, level=self.log_file_level):
Expand Down
7 changes: 1 addition & 6 deletions testing/logging/test_reporting.py
Expand Up @@ -916,12 +916,7 @@ def test_collection_live_logging(testdir):

result = testdir.runpytest("--log-cli-level=INFO")
result.stdout.fnmatch_lines(
[
"collecting*",
"*--- live log collection ---*",
"*Normal message*",
"collected 0 items",
]
["*--- live log collection ---*", "*Normal message*", "collected 0 items"]
)


Expand Down

0 comments on commit e865b27

Please sign in to comment.