Skip to content

Honor --cov as an override of source_pkgs in the coverage config - #753

Open
Sanjays2402 wants to merge 1 commit into
pytest-dev:masterfrom
Sanjays2402:fix/cov-source-overrides-source-pkgs
Open

Honor --cov as an override of source_pkgs in the coverage config#753
Sanjays2402 wants to merge 1 commit into
pytest-dev:masterfrom
Sanjays2402:fix/cov-source-overrides-source-pkgs

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #723

When a coverage config sets source_pkgs, an explicit --cov=<path> did not narrow the report: the plugin only passed source= to coverage.Coverage, so the configured source_pkgs were still added and every configured package stayed measured. This passes source_pkgs=[] whenever --cov was given an explicit value (which overrides the config); a bare --cov passes None and keeps honoring the config as before.

New test_central_explicit_cov_overrides_source_pkgs fails 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--cov does not apply with source_pkgs

1 participant