-
Notifications
You must be signed in to change notification settings - Fork 212
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
pytest gives "Coverage disabled via --no-cov switch!" warning even --no-cov is not given!! #284
Comments
It is more an issue with pytest-cov than pytest. From looking at the code there are only two places where it gets disabled: pytest-cov/src/pytest_cov/plugin.py Line 134 in 2d2aec1
See also pytest-dev/pytest#4938 - it would be useful here in general, but you can use it as a reference to see where to debug this within pytest. |
@iamabigstone are you sure you aren't setting PYTEST_ADDOPTS? Cleanup your environment variables. |
Somehow cannot repro this issue. closing |
I am facing the same annoying warning when I have
Environment should just take precedence over values configured in pytest.ini. |
Presence of I hope that this explains the reasoning behind silencing the warning, as it is just noise. Maybe another approach would be to make a a DEBUG level message, so it will not appear on normal executions. |
Avoids poluting stdout with a warning message which is unlikely to be caused by an accident (adding --no-cov switch) Fixes: pytest-dev#284
I know that this is closed, but the issue remains. Here's another use case from another voice: Coverage is enabled by default in pytest.ini with
But, while debugging, I want to suppress the coverage, so I add
|
I am glad I am not alone on this, as I didnt want to be the boy that cried wolf...;) IMHO, lots of issues could be fixed if we assure that installing coverage module does not activate any kind of coverage by default. It should need another option to activate it (config, cli, env). Just today I had to do a workaround on a project where I was running “pytest —collect-only” before running the test and coverage was producing multiple files and causing some problems on CI. |
You are using Apart from that I agree that |
The problem is that people are using it to configure the sources. It's like a workaround: activate coverage just to configure sources, then disable it for some one-off run. The previous maintainer (Marc?) has an idea or wip branch to remove the dual Anyway, I'll take a look again at #304 - looks like I forgot about it or closed it by accident. Does it solve most of the complaints? |
@ionelmc: What do you mean by "The problem is that people are using it to configure the sources." ? If you're saying that I've not configured this the way the pytest developers intended, I'm not offended or surprised: I do find configuring pytest + plugins to be confusing! What should I have done instead? |
@reece IMHO the problem is that you are enabling it by default. It's really useful on CI anyway (where it can be combined etc), but for local runs a "coverage" tox factor might be useful already also. I agree though that it should be not really a warning though also. |
But the you in that sentence is not necessarily the same you who's suffering from the problem; i.e. you might be working on a project where you have no control over |
One workaround would be to explicitly instruct pytest to ignore this specific warning: # pytest.ini:
filterwarnings =
error
ignore:Coverage disabled via --no-cov switch!:pytest.PytestWarning:pytest_cov.plugin This may be not ideal as you'd probably want it to explode in CI but at least it's less annoying. Besides, if you report coverage to third-parties, they'll probably alert you if the coverage suddenly drops anyway... |
I have not set --no-cov in any cli or configs, but it is given me the warning "Coverage disabled via --no-cov switch!". Even worse, I have enabled coverage in pytest.ini:
But coverage is not running!
Here is output:
pip list
from the virtual environment you are usingmyrepo_new.zip
The text was updated successfully, but these errors were encountered: