Skip to content

Instantly share code, notes, and snippets.

@AndreLouisCaron
Last active August 29, 2015 14:22
Show Gist options
  • Save AndreLouisCaron/c859efe3b061c7ce9895 to your computer and use it in GitHub Desktop.
Save AndreLouisCaron/c859efe3b061c7ce9895 to your computer and use it in GitHub Desktop.
Computing combined code coverage with Tox
[run]
source =
greet
[paths]
source =
.
.tox/py27/lib/python2.7/site-packages/
.tox/py34/lib/python3.4/site-packages/
.tox/pypy/site-packages/
.tox/pypy3/site-packages/
This snippet shows how to configure Tox to compute combined code coverage after all other tets have run.
Notes:
- replace `greet` with the name of your Python package;
- the `coverage` environment *must* appear last in `envlist`;
- `coverage combine` will delete all temporary `.coverage.{envname}` files and replace them with a single `.coverage` file;
- you can run `coverage html` after `tox` to get an HTML report that highlights the source lines that were not covered by any environment.
[tox]
envlist =
coverage-erase,
py34,
py27,
pypy3,
pypy,
coverage-report,
[testenv]
deps =
nose
coverage
setenv =
COVERAGE_FILE=.coverage.{envname}
commands =
coverage run -m nose greet
[testenv:coverage-erase]
deps =
coverage
commands =
coverage erase
[testenv:coverage-report]
deps =
coverage
setenv =
COVERAGE_FILE=.coverage
commands =
coverage combine
coverage report --fail-under=100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment