[TIP] Make tox and coverage play together more nicely?

Ned Batchelder ned at nedbatchelder.com
Sun Nov 16 09:16:05 PST 2014

On 11/12/14 5:15 PM, Barry Warsaw wrote:
> I wonder if anything can or should be done to make tox and coverage work
> better together.  In particular, I have to add some icky and fragile code to
> my coverage.ini to get reasonable results from a `tox -e coverage` run.
> -----snip snip-----
> [run]
> branch = true
> parallel = true
> omit =
>       setup*
>       */showme.py
>      .tox/coverage/lib/python2.7/site-packages/*
> [paths]
> source =
>      mailman
>      .tox/coverage/lib/python*/site-packages/mailman
> -----snip snip-----
> I don't like having to equivalence the in-tree directory ('mailman') with the
> tox venv site-packages directory, but this is necessary because some tests run
> from executables created in the venv.  I'd like for coverage to do the [paths]
> bits automatically when it detects its running under tox.

If I understand you correctly, this would require coverage to 
automatically understand that .../site-packages/mailman is your own 
code.  I don't see how it could do that.
> I also don't like having to explicitly omit everything else in the tox venv's
> site-packages.  It seems like since coverage already omits stuff in the
> system's site-packages, it could do the same with the tox venv site-packages.

Usually the best way to omit things from site-packages is to use the 
--source=. (or some other value) setting.  In your case, it looks like 
it would be:

     source =

Would that work?

> Cheers,
> -Barry
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20141116/c5b220de/attachment.html>

More information about the testing-in-python mailing list