Fix for Verbose mode not having default value on getoption call works on issue #9422#12706
Fix for Verbose mode not having default value on getoption call works on issue #9422#12706nicoddemus merged 8 commits intopytest-dev:mainfrom
Conversation
…if not assigned
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Thanks @GTowers1.
Since then we have introduced Config.get_verbosity:
pytest/src/_pytest/config/__init__.py
Line 1731 in 9446f02
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
So can you please:
-
Replace
config.getoption("verbose")calls byconfig.get_verbosity(). -
Create an integration test in
test_config.pythat executes a simple test file with the terminal plugin disabled, and ensures pytest finishes with success (0). -
Fix
Config.get_verbosityso it returns0ifself.option.verboseis not defined -- basically changeself.option.verbosebyself.getoption("verbose", 0)here:pytest/src/_pytest/config/__init__.py
Line 1762 in 9446f02
nicoddemus
left a comment
There was a problem hiding this comment.
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