[TIP] tox and coverage across multiple envs
Andrew Dalke
dalke at dalkescientific.com
Wed Aug 10 00:42:40 PDT 2011
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)
./tox/py27-oe174
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
.tox/py27-oe174/lib/python2.7/site-packages/chemfp
but for another environment it's put into
.tox/py27-ob23svn1/lib/python2.7/site-packages/chemfp/
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
.tox/py27-oe174/lib/python2.7/site-packages/chemfp/openbabel.py
-or-
.tox/py27-ob23svn1/lib/python2.7/site-packages/chemfp/openbabel.py
-or-
...
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
.tox/.*/site-packages/
though I don't know if that's a generally useful practice.
Perhaps there's an easy way to hack the .coverage.* format?
Andrew
dalke at dalkescientific.com
More information about the testing-in-python
mailing list