From 18aae33066462b9e744b3b81ff72372e03835333 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 17 May 2023 15:49:38 +0100 Subject: [PATCH] Correct coverage settings (#273) --- .gitignore | 1 + pyproject.toml | 6 +++++- tox.ini | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1e0fcf81..2cfccf56 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dmypy.json # Pyre type checker .pyre/ .test-results +*.lcov diff --git a/pyproject.toml b/pyproject.toml index e6c66538..f5abbc3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,11 @@ test = ["coverage", "pip-tools", "pytest>=7.2.0", "pytest-mock", "pytest-plus"] [tool.coverage.run] source = ["src"] -branch = true +# Do not use branch until bug is fixes: +# https://github.com/nedbat/coveragepy/issues/605 +branch = false +parallel = true +concurrency = ["multiprocessing", "thread"] [tool.coverage.report] exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] diff --git a/tox.ini b/tox.ini index 2624a50c..1e6eadca 100644 --- a/tox.ini +++ b/tox.ini @@ -35,12 +35,20 @@ commands = # We add coverage options but not making them mandatory as we do not want to force # pytest users to run coverage when they just want to run a single test with `pytest -k test` coverage run -m pytest {posargs:} - sh -c "coverage xml || true && coverage report" + sh -c "coverage combine -a -q --data-file=.coverage {toxworkdir}/.coverage.*" + # needed for upload to codecov.io + -sh -c "COVERAGE_FILE= coverage xml --ignore-errors -q --fail-under=0" + # needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403 + -sh -c "COVERAGE_FILE= coverage lcov --ignore-errors -q --fail-under=0" + sh -c "COVERAGE_FILE= coverage report" # We fail if files are modified at the end git diff --exit-code + commands_pre = # safety measure to assure we do not accidentally run tests with broken dependencies {envpython} -m pip check + # cleaning needed to prevent errors between runs + sh -c "rm -f .coverage {toxworkdir}/.coverage.* 2>/dev/null || true" passenv = CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437 FORCE_COLOR @@ -56,6 +64,7 @@ passenv = setenv = ANSIBLE_DEVEL_WARNING='false' COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} + COVERAGE_PROCESS_START={toxinidir}/pyproject.toml PIP_DISABLE_PIP_VERSION_CHECK = 1 PIP_CONSTRAINT = {toxinidir}/requirements.txt PRE_COMMIT_COLOR = always