Skip to content
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

Introduce --cov-reset option to reset --cov=* values set so far #460

Open
dsegan opened this issue Mar 25, 2021 · 0 comments
Open

Introduce --cov-reset option to reset --cov=* values set so far #460

dsegan opened this issue Mar 25, 2021 · 0 comments

Comments

@dsegan
Copy link
Contributor

dsegan commented Mar 25, 2021

It is sometimes useful to "reset" all the --cov=X options passed in "so far", eg.

  pytest --cov=app --cov-reset --cov=app/module

would only check for coverage on app/module instead of checking the coverage on all modules in app.

My particular use case is to allow getting coverage from both local pytest and tox runs (tox is slower :)), yet keep tox using the installed package:

pytest.ini:

[pytest]
addopts = . --cov=package --cov-report=term-missing

tox.ini:

[tox]
envlist = py37,py38,py39

[testenv]
commands = 
    pytest . --cov-reset --cov={envsitepackagesdir}/package

Without the reset option, tox runs will include coverage on both the installed package and local copy (which is always zero).

As a bonus, such a simple implementation of --cov-reset could even be used to replace --no-cov altogether (the only requirement being that --cov-reset has to go after all the --cov options), so it's more flexible and a much simpler implementation. However, one would have to think carefully about all the use cases for no-cov (debuggers are mentioned)

Here's a pull request if you think this is worthwhile: #459

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

No branches or pull requests

1 participant