[TIP] C-extension coverage

David Cournapeau cournape at gmail.com
Mon Apr 16 17:17:57 PDT 2012


On Wed, Apr 11, 2012 at 8:49 PM, francis <francismb at email.de> wrote:

> Hi all,
>
> I would like to have line and branch coverage of a Python C-extension by
> using gcc-coverage (gcov). AFAIN to be able to use gcov for that, the
> extension
> module has to be compiled statically: means in that case the interpreter,
> the
> tests (written in python with unittest) and the C-extension itself. I
> wonder if that
> can be achieved with py2exe or some of it's pendants...
>
> If someone has already gone that path or did something similar … any idea
> is
> appreciated.
>

That's tricky. As you mentioned, gcov does not work with shared libraries
as is, so you need to statically link your extensions into python: that's
not easy either.

I think in the short term, using clang new coverage abilities is the most
promising approach, but it is still unstable in my experience:

http://mattrajca.com/post/8749868513/llvm-code-coverage-and-xcode-4

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20120417/da0f6a95/attachment.htm>


More information about the testing-in-python mailing list