[TIP] tox and coverage across multiple envs

Andrew Dalke dalke at dalkescientific.com
Tue Aug 9 01:20:42 PDT 2011

I've been slowly getting 14 different environments set up under tox.
These have different combinations of Python version and with/without
various third-party packages.

My code contains various configuration checks. Eg, if a library
is too old and doesn't have a built in "get version" function then
I provide a function which figures out the version through other ways.

      from openbabel import OBReleaseVersion 
  except ImportError: 
      OBReleaseVersion = _emulated_OBReleaseVersion 
  _ob_version = OBReleaseVersion()

My tox setup now works. Yeah!

I want to generate coverage tests so I can double-check that I'm
testing both branches of the above.

I tried to generate coverage for each environment using:

coverage run -p ./tests/unit2 discover -s tests

followed by the usual "coverage combine" / "coverage html".

This did not work as I wanted. I got coverage information
with names to each of the modules, as in:


I wanted coverage for all of the chemfp/openbabel.py
files merged into one.

Is there any way to do what I want?

Also, when the tests find an error, I find that it's hard
to get to a reproducible state because each of my environments
has different environment variables. (LD_LIBRARY_PATH, path
to license file, etc.) Is there any way to do something like

tox -e py26-rd201106 --run python

and get me into that specific Python along with the right
environment setup? Or is there some other way to handle this?

				dalke at dalkescientific.com

More information about the testing-in-python mailing list