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

Rachit Sinha rachit.sinha at nutanix.com
Wed Mar 1 23:34:15 PST 2017

Any information on this? My project is stuck because of the unavailability of a suitable Python code coverage tool for my requirement.

Looking forward to hearing from you.


From: Rachit Sinha <rachit.sinha at nutanix.com>
Date: Wednesday, 1 March 2017 at 8:26 PM
To: "testing-in-python at lists.idyll.org" <testing-in-python at lists.idyll.org>
Subject: Can coverage.py be used to collect coverage data for Functional or integration tests?


I was currently looking for a code coverage tool for source code in python. My requirement was that –

1)      The coverage tool should have an agent that starts when initiated and starts measuring code for the source files specified.

2)      The tests are run separately, using our test execution framework, that in turn will execute the source code and hence coverage tool will generate coverage data

3)      Once the tests are completed, the user stops the coverage tool agent

4)      Then the user generates coverage report using appropriate methods.

I came across your tool- coverage.py and was going through its documentation. From what I understood, coverage.py works on unit tests only.

The syntax for running coverage.py,

coverage run --source=dir1,dir2 my_program.py arg1 arg2

suggests to me that my_program.py is the test case here which runs with coverage to collect data for files present in directories specified by `--source`.

But I need my tests to run independently of the coverage tool. The coverage tool should be spawned separately (like a java agent) and just record the data in the source files generated by the execution of the tests.

Can you please let me know whether I can use coverage.py for the purpose stated?

Please reach out to me in case of any questions on the stated purpose.

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

More information about the testing-in-python mailing list