File tree 3 files changed +33
-2
lines changed
3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1
1
[run]
2
+ parallel = True
2
3
branch = True
4
+ source = hypothesis
3
5
omit =
4
6
**/_hypothesis_ftz_detector.py
5
7
**/_hypothesis_pytestplugin.py
Original file line number Diff line number Diff line change @@ -212,6 +212,26 @@ loading our pytest plugin from your ``conftest.py`` instead::
212
212
echo "pytest_plugins = ['hypothesis.extra.pytestplugin']\n" > tests/conftest.py
213
213
pytest -p "no:hypothesispytest" ...
214
214
215
+ Another alternative, which we in fact use in our CI self-tests because it works
216
+ well also with parallel tests, is to automatically start coverage early for all
217
+ new processes if an environment variable is set.
218
+ This automatic starting is set up by the PyPi package :pypi: `coverage_enable_subprocess `.
219
+
220
+ This means all configuration must be done in ``.coveragerc ``, and not on the
221
+ command line::
222
+
223
+ [run]
224
+ parallel = True
225
+ source = ...
226
+
227
+ Then, set the relevant environment variable and run normally::
228
+
229
+ python -m pip install coverage_enable_subprocess
230
+ export COVERAGE_PROCESS_START=$PATH/.coveragerc
231
+ pytest [-n auto] ...
232
+ coverage combine
233
+ coverage report
234
+
215
235
216
236
.. _alternative-backends :
217
237
Original file line number Diff line number Diff line change @@ -218,20 +218,29 @@ allowlist_externals =
218
218
setenv =
219
219
PYTHONWARNDEFAULTENCODING =1
220
220
HYPOTHESIS_INTERNAL_COVERAGE =true
221
+ COVERAGE_PROCESS_START =.coveragerc
221
222
commands_pre =
222
223
rm -f branch-check*
223
224
pip install .[zoneinfo]
225
+ pip install coverage_enable_subprocess
226
+ commands_post =
227
+ pip uninstall -y coverage_enable_subprocess
224
228
# Produce a coverage report even if the test suite fails.
225
229
# (The tox task will still count as failed.)
226
230
ignore_errors = true
231
+ # We've had problems correctly measuring coverage using pytest-cov when running
232
+ # in parallel, so instead we start coverage implicitly on all (sub-)processes by
233
+ # way of the coverage_enable_subprocesses installation. This requires all options
234
+ # to be set in .coveragerc (including source), but that's ok as it is overridden
235
+ # by --cov=... in conjecture-coverage.
227
236
commands =
228
- python -bb -X dev -m coverage run -- rcfile =.coveragerc -- source =hypothesis -m pytest -n0 --ff {posargs} \
237
+ python -bb -X dev -m pytest -n auto --ff {posargs} \
229
238
tests/cover tests/conjecture tests/datetime tests/numpy tests/pandas tests/lark \
230
239
tests/redis tests/dpcontracts tests/codemods tests/typing_extensions tests/patching tests/test_annotated_types.py
240
+ python -m coverage combine
231
241
python -m coverage report
232
242
python scripts/validate_branch_check.py
233
243
234
-
235
244
[testenv:conjecture-coverage]
236
245
deps =
237
246
-r../requirements/coverage.txt
You can’t perform that action at this time.
0 commit comments