[TIP] Can coverage.py be used to collect coverage data for Functional or integration tests?

Florian Bruhin me at the-compiler.org
Thu Mar 2 01:07:32 PST 2017

* Rachit Sinha <rachit.sinha at nutanix.com> [2017-03-02 08:55:08 +0000]:
> Coming to your 1st Question. Coverage.py can run as an external
> agent which gets attached to the process for which  coverage data is
> to be gathered.

Only if Python provides a way to do that - which to my knowledge, it
does not.

(You *could* probably attach via gdb and use that to trace what Python
code is being executed - but it's going to be painful and horribly
slow :P)

> Can coverage.py work with an external framework? Our company has its own command line tests framework.
> So can coverage.py be integrated with it?
> If so, can you or anyone share with me the procedure for the same?

coverage.py doesn't care what test framework you're using. Think of it
as a wrapper around a Python process - you can also just do:

   coverage run python foo.py

without any test framework involved.

So either just run your entire test framework under coverage, or do
something like what pytest-cov does:

(alternatively, stop using your own test framework and extend
something more common instead :P)


http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170302/d6102d2e/attachment.pgp>

More information about the testing-in-python mailing list