[TIP] how to configure automated python testing and code coverage reports
marius at gedmin.as
Wed Dec 19 01:20:39 PST 2018
On Tue, Dec 18, 2018 at 03:44:46PM +0000, DZIOBEK, JOE wrote:
> 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
> 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
coverage run -m pytest --ignore=...
coverage report -m
And add a .coveragerc with
source = .
I'm not sure what the "--ignore=virtualenv-15.1.0/" bit is about. If
you find coverage report reporting about paths in virtualenv-15.1.0/,
you may need to add an
omit = virtualenv-15.1.0/*
or something similar to the .coveragerc.
Experience varies directly with equipment ruined.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 195 bytes
Desc: not available
More information about the testing-in-python