Skip to content

Fix for Verbose mode not having default value on getoption call works on issue #9422#12706

Merged
nicoddemus merged 8 commits intopytest-dev:mainfrom
GTowers1:main
Sep 5, 2024
Merged

Fix for Verbose mode not having default value on getoption call works on issue #9422#12706
nicoddemus merged 8 commits intopytest-dev:mainfrom
GTowers1:main

Conversation

@GTowers1
Copy link
Copy Markdown
Contributor

@GTowers1 GTowers1 commented Aug 10, 2024

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

@nicoddemus nicoddemus added skip news used on prs to opt out of the changelog requirement and removed skip news used on prs to opt out of the changelog requirement labels Aug 13, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Aug 13, 2024
Copy link
Copy Markdown
Member

@nicoddemus nicoddemus left a 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:

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:

global_level = self.option.verbose

So can you please:

  1. Replace config.getoption("verbose") calls by config.get_verbosity().

  2. 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).

  3. Fix Config.get_verbosity so it returns 0 if self.option.verbose is not defined -- basically change self.option.verbose by self.getoption("verbose", 0) here:

    global_level = self.option.verbose

Copy link
Copy Markdown
Member

@nicoddemus nicoddemus left a 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.

@nicoddemus nicoddemus merged commit 72c682f into pytest-dev:main Sep 5, 2024
@patchback
Copy link
Copy Markdown

patchback bot commented Sep 5, 2024

Backport to 8.3.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.3.x/72c682ff9773ad2690711105a100423ebf7c7c15/pr-12706

Backported as #12778

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Sep 5, 2024
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)
nicoddemus pushed a commit that referenced this pull request Sep 5, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants