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

Rachit Sinha rachit.sinha at nutanix.com
Thu Mar 2 01:17:12 PST 2017


Hi Florian,


Suppose my framework gets initiated when I execute if from command prompt.

For eg – Framework binary file is – agave. So we run like this –

Agave <tests> <test_args> <other_options>

My question is how do I invoke it from coverage.py?

The tests are designed in such a way that they can only run inside the framework. Python compiler is not enough to run them.

So only option left for me is to integrate coverage.py with my framework.

Thanks,
Rachit


On 02/03/17, 2:37 PM, "Florian Bruhin" <me at the-compiler.org> wrote:

>* 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:
>https://github.com/pytest-dev/pytest-cov/tree/master/src/pytest_cov
>
>(alternatively, stop using your own test framework and extend
>something more common instead :P)
>
>Florian
>
>-- 
>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/



More information about the testing-in-python mailing list