Skip to content

Commit

Permalink
Correct coverage settings (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored May 17, 2023
1 parent 680e568 commit 18aae33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json
# Pyre type checker
.pyre/
.test-results
*.lcov
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:"]
Expand Down
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 18aae33

Please sign in to comment.