From 06f1278dbded2dfc19ccdf723d50a3c42df570ac Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 17 Oct 2017 13:21:06 +0200 Subject: [PATCH] Run pytest inside tox with coverage --- .coveragerc | 34 ++++++++++++++++++++++++++++++++++ .travis.yml | 11 +++++++---- tox.ini | 19 +++++++++++++++++-- 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..e06bdf297 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,34 @@ +[run] +# measure 'branch' coverage in addition to 'statement' coverage +# See: http://coverage.readthedocs.org/en/coverage-4.0.3/branch.html#branch +branch = True + +# list of directories or packages to measure +source = ufo2ft + +# these are treated as equivalent when combining data +[paths] +source = + Lib/ufo2ft + .tox/*/lib/python*/site-packages/ufo2ft + .tox/pypy*/site-packages/ufo2ft + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # keywords to use in inline comments to skip coverage + pragma: no cover + + # don't complain if tests don't hit defensive assertion code + raise AssertionError + raise NotImplementedError + + # don't complain if non-runnable code isn't run + if 0: + if __name__ == .__main__.: + +# ignore source code that can’t be found +ignore_errors = True + +# when running a summary report, show missing lines +show_missing = True diff --git a/.travis.yml b/.travis.yml index 06ebe5cb2..ef91fedf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,17 @@ sudo: false language: python -python: - - "2.7" - - "3.6" +matrix: + include: + - python: 2.7 + env: TOXENV=py27-cov + - python: 3.6 + env: TOXENV=py36-cov branches: only: - master - /^v\d+\.\d+.*$/ -install: pip install tox-travis +install: pip install tox script: tox deploy: diff --git a/tox.ini b/tox.ini index e3ed614a7..a62cba91a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,24 @@ [tox] -envlist = py27, py36 +envlist = py{27,36}-cov, htmlcov [testenv] deps = + cov: coverage pytest -rrequirements.txt commands = - py.test {posargs} + # run the test suite against the package installed inside tox env. + # We use parallel mode and then combine later so that coverage.py will take + # paths like .tox/py36/lib/python3.6/site-packages/fontTools and collapse + # them into Lib/fontTools. + cov: coverage run --parallel-mode -m pytest {posargs} + nocov: pytest {posargs} + +[testenv:htmlcov] +basepython = python3.6 +deps = + coverage +skip_install = true +commands = + coverage combine + coverage html