-
Notifications
You must be signed in to change notification settings - Fork 214
How to programmatically disable coverage? #418
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
Comments
See if #241 (comment) still works. I guess there should be at least something documented about this. |
That technique does not seem to be having the desired effect. See the referenced PR on Setuptools, where the PyPy tests take ~17 minutes to run, whereas with coverage disabled, they take ~6 minutes to run. |
Ok so I have to think a bit how to give a nice api for this, but meanwhile try this: def pytest_configure(config):
cov = config.pluginmanager.get_plugin('_cov')
cov.options.no_cov = True If stuff is still slow try to add this: if cov.cov_controller:
cov.cov_controller.pause() |
In pypa/setuptools#2254, I learned that |
I'd like to be able to programmatically disable coverage tests based on some runtime condition. In particular, on Setuptools, when running tests against PyPy, enabling coverage is prohibitively expensive (~3x run time). I'd like to be able to enable coverage tests by default, but when PyPy is detected (probably in conftest.py), disable the coverage.
I'd like to enable coverage by default by setting
[pytest] addopts=--cov
, but have that not take effect when running on PyPy. I've tried usingtox
functionality to secondarily disable by passing--no-cov
, but even tox can't detect when PyPy is running; it can only detect when an environment namedpypy
orpypy3
is indicated, but sometimes, tox is invoked from within PyPy, so the env name ispy
orpython
, but the interpreter is still PyPy.Is there a way within conftest to disable the coverage behavior based on arbitrary Python logic? What incantations would be necessary at what hook point to disable coverage? Thanks!
The text was updated successfully, but these errors were encountered: