From 9f47efe757762351ec12b4303e747ac0774db991 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 Jul 2020 02:54:32 -0400 Subject: Programmatically disable coverage when running on PyPy. --- conftest.py | 18 ++++++++++++++++++ tox.ini | 4 ---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index 1746bfb5..0bc8d320 100644 --- a/conftest.py +++ b/conftest.py @@ -17,6 +17,24 @@ collect_ignore = [ ] +def pytest_configure(config): + disable_coverage_on_pypy(config) + + +def disable_coverage_on_pypy(config): + """ + Coverage makes tests on PyPy unbearably slow, so disable it. + """ + if '__pypy__' not in sys.builtin_module_names: + return + + # Recommended at pytest-dev/pytest-cov#418 + cov = config.pluginmanager.get_plugin('_cov') + cov.options.no_cov = True + if cov.cov_controller: + cov.cov_controller.pause() + + if sys.version_info < (3,): collect_ignore.append('setuptools/lib2to3_ex.py') collect_ignore.append('setuptools/_imp.py') diff --git a/tox.ini b/tox.ini index 59213e88..9ce5cb5c 100644 --- a/tox.ini +++ b/tox.ini @@ -29,10 +29,6 @@ extras = tests -[testenv:pypy{,3}] -commands = pytest --no-cov {posargs} - - [testenv:coverage] description=Combine coverage data and create report deps=coverage -- cgit v1.2.3