[TIP] tox and coverage across multiple envs

Andrew Dalke dalke at dalkescientific.com
Sat Sep 10 03:59:17 PDT 2011


Hi Ned,

  Working with tox is both cool and frustrating. I rebuilt the entire tox tree so each environment has the new version of coverage, only to forget that the "coverage" I use to combine and to generate HTML is the system installed version.

  With that in place I get this error:

% coverage --version
Coverage.py, version 3.5.1b1.  http://nedbatchelder.com/code/coverage/3.5.1b1

% coverage html
Couldn't parse '/Users/dalke/cvses/chem-fingerprints/.tox/py25-ob223/lib/python2.5/site-packages/chemfp/commandline/cmdsupport.py' as Python source: 'invalid syntax' at line 23

% head -24 /Users/dalke/cvses/chem-fingerprints/.tox/py25-ob223/lib/python2.5/site-packages/chemfp/commandline/cmdsupport.py | tail -6

def sys_exit_opener(opener, source, format, id_tag, aromaticity):
    try:
        return opener.read_structure_fingerprints(source, format, id_tag, aromaticity)
    except (IOError, ChemFPError), err:
        raise SystemExit("Cannot read structure fingerprints: %s\n" % err)



That looks like perfectly valid code to me, and Python agrees.

In any case, the "ChemFPError" is no longer needed so I removed it, only to have the same problem:

% coverage html
Couldn't parse '/Users/dalke/cvses/chem-fingerprints/.tox/py25-ob223/lib/python2.5/site-packages/chemfp/commandline/cmdsupport.py' as Python source: 'invalid syntax' at line 23

% head -25 /Users/dalke/cvses/chem-fingerprints/.tox/py25-ob223/lib/python2.5/site-packages/chemfp/commandline/cmdsupport.py | tail -7

def sys_exit_opener(opener, source, format, id_tag, aromaticity):
    try:
        return opener.read_structure_fingerprints(source, format, id_tag, aromaticity)
    except IOError, err:
        raise SystemExit("Cannot read structure fingerprints: %s\n" % err)

What's going on?

> I hope this will work to solve your problem.  Try it out when you get a chance, and let me know if something needs to be improved.  In particular, combining across OSes is a concern.


My .coveragerc contains 

[paths]
chemfp =
 chemfp
 .tox/py25-ob223/lib/python2.5/site-packages/chemfp
 .tox/py25-ob223/lib/python2.5/site-packages/chemfp
 .tox/py25-ob230/lib/python2.5/site-packages/chemfp
 .tox/py25-ob230/lib/python2.5/site-packages/chemfp
 .tox/py25-oe174/lib/python2.5/site-packages/chemfp
   ... many more lines deleted ...

My first version however omitted the "chemfp" line. I had

[paths]
chemfp =
 .tox/py25-ob223/lib/python2.5/site-packages/chemfp
  ...

This is because I thought that all the path names
would be replaced with the left-hand-side of the
field.

Only later did I read:

   The first value must be an actual file path on the machine where
   the reporting will happen, so that source code can be found.

What about this variant?

[paths]
/path/to/local/chemfp =
 .tox/py25-ob223/lib/python2.5/site-packages/chemfp
 .tox/py25-ob223/lib/python2.5/site-packages/chemfp



				Andrew
				dalke at dalkescientific.com





More information about the testing-in-python mailing list