[TIP] how to configure automated python testing and code coverage reports

DZIOBEK, JOE jd5948 at att.com
Tue Dec 18 07:44:46 PST 2018

I am a python pytest newbie, and am trying to configure automated python testing and code coverage reports.
The source code folder structure is as follows:


I want to configure tox to

1)      Execute all test-*.py scripts

2)      Find all .py scripts, and calculate their test coverage

3)      Eventually I also want to upload this coverage report to sonar

With below tox.ini:

1)      All test_*.py scripts are found and executed

2)      Coverage is only reported for the specific test_scriptA.py I list. If I omit the specific test, I get errors.

How can I configure 'coverage' to find all py files, and report on their coverage?

This is what I have so far in my tox.ini:

deps = pytest

commands =
    pytest --ignore=virtualenv-15.1.0/
    coverage run subfolder/test_scriptA.py
    coverage report -m

Thanks for any advice - Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20181218/32e8cc13/attachment.html>

More information about the testing-in-python mailing list