Honor --cov as an override of source_pkgs in the coverage config - #753
Open
Sanjays2402 wants to merge 1 commit into
Open
Honor --cov as an override of source_pkgs in the coverage config#753Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
When a coverage config file set source_pkgs, an explicit --cov=<path> did not narrow the report: pytest-cov only passed source= to coverage.Coverage, so the config's source_pkgs were still added and every configured package was measured. Pass source_pkgs=[] whenever --cov was given an explicit value, which overrides the config value. A bare --cov (cov_source is None) passes source_pkgs=None and keeps honoring the config as before. Adds a regression test that fails without the fix. Closes pytest-dev#723
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #723
When a coverage config sets
source_pkgs, an explicit--cov=<path>did not narrow the report: the plugin only passedsource=tocoverage.Coverage, so the configuredsource_pkgswere still added and every configured package stayed measured. This passessource_pkgs=[]whenever--covwas given an explicit value (which overrides the config); a bare--covpassesNoneand keeps honoring the config as before.New
test_central_explicit_cov_overrides_source_pkgsfails without the source change and passes with it.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.