-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix verbosity bug in --collect-only #5391
Conversation
@@ -628,6 +624,10 @@ def pytest_sessionstart(self): | |||
@pytest.hookimpl(hookwrapper=True) | |||
def pytest_runtestloop(self, session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit surprised that this hook is called even when --collect-only is used
Codecov Report
@@ Coverage Diff @@
## master #5391 +/- ##
==========================================
- Coverage 95.98% 95.98% -0.01%
==========================================
Files 114 114
Lines 25496 25512 +16
Branches 2474 2478 +4
==========================================
+ Hits 24473 24488 +15
Misses 718 718
- Partials 305 306 +1
Continue to review full report at Codecov.
|
Thanks @Thisch for the quick PR! While it fixes the main problem, using
|
Do we still want to capture log messages during diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py
index f8ff0362c..1cffda1c3 100644
--- a/src/_pytest/logging.py
+++ b/src/_pytest/logging.py
@@ -624,16 +624,19 @@ class LoggingPlugin:
@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):
+ if session.config.option.collectonly:
+ yield
+ else:
+ 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):
+ yield # run all the tests
+ else:
yield # run all the tests
- else:
- yield # run all the tests |
I dont understand your comment. live-logging/capturing of the log messages that are created in the collection phase still works, even with your patch. Note that I've already applied your patch, thx! |
Sorry, I was not very clear: I meant that my patch fixes the output difference from my previous comment (the |
Fix verbosity bug in --collect-only
Backport: #5411 |
[4.6] Fix verbosity bug in --collect-only (backport of #5391)
Closes: #5383
master
branch for bug fixes, documentation updates and trivial changes.features
branch for new features and removals/deprecations.Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
changelog
folder, with a name like<ISSUE NUMBER>.<TYPE>.rst
. See changelog/README.rst for details.AUTHORS
in alphabetical order;