Skip to content

Commit 3319bfa

Browse files
authored
Merge pull request #2254 from pypa/better-cov
Programmatically disable coverage when running on PyPy.
2 parents a494597 + 9f47efe commit 3319bfa

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ def pytest_addoption(parser):
1919
]
2020

2121

22+
def pytest_configure(config):
23+
disable_coverage_on_pypy(config)
24+
25+
26+
def disable_coverage_on_pypy(config):
27+
"""
28+
Coverage makes tests on PyPy unbearably slow, so disable it.
29+
"""
30+
if '__pypy__' not in sys.builtin_module_names:
31+
return
32+
33+
# Recommended at pytest-dev/pytest-cov#418
34+
cov = config.pluginmanager.get_plugin('_cov')
35+
cov.options.no_cov = True
36+
if cov.cov_controller:
37+
cov.cov_controller.pause()
38+
39+
2240
if sys.version_info < (3,):
2341
collect_ignore.append('setuptools/lib2to3_ex.py')
2442
collect_ignore.append('setuptools/_imp.py')

tox.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ extras =
2727
tests
2828

2929

30-
[testenv:pypy{,3}]
31-
commands = pytest --no-cov {posargs}
32-
33-
3430
[testenv:coverage]
3531
description=Combine coverage data and create report
3632
deps=coverage

0 commit comments

Comments
 (0)