-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 for Verbose mode not having default value on getoption call works on issue #9422 #12706
Conversation
…if not assigned
for more information, see https://pre-commit.ci
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.
Thanks @GTowers1.
Since then we have introduced Config.get_verbosity
:
pytest/src/_pytest/config/__init__.py
Line 1731 in 9446f02
def get_verbosity(self, verbosity_type: str | None = None) -> int: |
So we should be calling that instead of config.getoption("verbose")
. I also noticed that get_verbosity
does not handle the possibility of verbose
not being defined:
pytest/src/_pytest/config/__init__.py
Line 1762 in 9446f02
global_level = self.option.verbose |
So can you please:
-
Replace
config.getoption("verbose")
calls byconfig.get_verbosity()
. -
Create an integration test in
test_config.py
that executes a simple test file with the terminal plugin disabled, and ensures pytest finishes with success (0
). -
Fix
Config.get_verbosity
so it returns0
ifself.option.verbose
is not defined -- basically changeself.option.verbose
byself.getoption("verbose", 0)
here:pytest/src/_pytest/config/__init__.py
Line 1762 in 9446f02
global_level = self.option.verbose
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.
Took the liberty of applying the changes myself. 👍
Will leave this up for a few days to give others a chance to review.
Backport to 8.3.x: 💚 backport PR created✅ Backport PR branch: Backported as #12778 🤖 @patchback |
Instead of calling `Config.option.verbose`, call the new `Config.get_verbosity` function to determine the verbosity level. This enables pytest to run correctly with the terminal plugin disabled. Fix #9422 (cherry picked from commit 72c682f) Co-authored-by: GTowers1 <130098608+GTowers1@users.noreply.github.com>
Followed the suggestions on this issue and added a default value to the verbose mode calls as it does in some of the other sections of the code.
Refs #9422