-
Notifications
You must be signed in to change notification settings - Fork 219
Description
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 using tox
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 named pypy
or pypy3
is indicated, but sometimes, tox is invoked from within PyPy, so the env name is py
or python
, 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!