[TIP] tox and coverage across multiple envs
memedough at gmail.com
Wed Aug 10 02:33:15 PDT 2011
The coverage data file stores the paths and they are different for the
various tox environments.
Before you combine them with coverage you need to rewrite the paths so
that they appear to be in the same location. Then tell coverage to
You could easily write a small script to load each coverage data file
using the coverage api, see
Give it the name of the data file to load, load it, rewrite the
filenames in the data.lines and data.arcs and save it out. For an
example see (right down the bottom)
Then do the normal combine and the paths will match to combine the results.
On 10 August 2011 17:42, Andrew Dalke <dalke at dalkescientific.com> wrote:
> Hi Ned,
> On Aug 10, 2011, at 2:32 AM, Ned Batchelder wrote:
>> I don't understand what those file names are that you're showing.
>> You should have gotten data files like .coverage.machine.pid.12345 .
>> And then "coverage combine" should have created a single .coverage
>> file from them. I'm not familiar with tox, is there something it
>> does to affect the coverage collection?
> Each tox environment has a name, like "py27-oe174" or "py27-ob23svn1",
> and an associated configuration. Each configuration may have
> dependencies. Tox makes a virtualenv for py27-oe174 under the
> directory (this includes any extra download/installs)
> To run an environment, it appears that tox does a "setup.py install"
> into the associated directory. For this environment the module
> is put into
> but for another environment it's put into
> Then because of the tox "commands" setting of
> coverage run -p ./tests/unit2 discover -s tests
> tox runs the environment specific "coverage".
> This puts the various .coverage.machine.pid.12345 files into
> my top-level directory, which I can collect.
> The problem is that each tox environment has its own PYTHONPATH,
> so that "from chemfp import openbabel" refers to
> depending on the environment that I run. This is how tox
> maintains the needed isolation.
> The problem is that I want to merge those different reports
> into one. In my case I can get what I want by removing
> though I don't know if that's a generally useful practice.
> Perhaps there's an easy way to hack the .coverage.* format?
> dalke at dalkescientific.com
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
More information about the testing-in-python