[TIP] Getting combined coverage with Tox

André Caron andre.l.caron at gmail.com
Wed Jun 3 21:02:16 PDT 2015


Hi all,

I've been searching for a recipe for computing combined code coverage while
running Tox to against multiple versions of dependencies.

I found an old thread on this list (dates back to Aug 2011) that discusses
this, but there is no clear conclusion:


http://lists.idyll.org/pipermail/testing-in-python/2011-August/004310.html

I've managed to hack something using some hints from there and some other
tips here and there.  Here's a stripped-down version of what I'm using ATM:

[tox]
envlist = py34,py27,coverage

[testenv:py34]
deps =
  nose
  coverage
setenv =
  COVERAGE_FILE=.coverage.{envname}
commands =
  python setup.py check
  coverage run -m nose greet

[testenv:py27]
deps =
  nose
  coverage
setenv =
  COVERAGE_FILE=.coverage.{envname}
commands =
  python setup.py check
  coverage run -m nose greet

[testenv:coverage]
deps =
  coverage
commands =
  coverage combine
  coverage report --show-missing --fail-under=100


Notice that I'm using the "envlist" setting to force the "coverage"
environment to run last.  This has the downside that I must list *all*
environments there.  Appart from being tedious to read (CSV on one single
line), I get the risk that someone forgets to add a new environment's name
to the list.

Do you have any suggestions or know of any alternative ways of doing this?

Thanks!

André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150604/cfbf85f1/attachment.htm>


More information about the testing-in-python mailing list