Python coverage example
Add the following to your
yml language: python after_success: - bash
Produce Coverage Reports
coverage.py is required to collect coverage metrics.
Below are some examples on how to include coverage tracking during your tests. Codecov will callcoveragexml -iautomatically to generate the coverage xml output, which will be archived and processed server side.
You may need to configure a.coveragercfile. Learn more here. Start with this generic .coveragerc for example.
We highly suggest addingsourceto your.coveragercwhich solves a number of issues collecting coverage.[run] source=your_package_name
unittestspip install coverage coverage run tests.py
See the Offical Nose coverage docs for more information.
Codecov can be run from inside yourtox.iniplease make sure you pass all the necessary environment variables through:ini [testenv] passenv = CI TRAVIS TRAVIS_* deps = codecov commands = codecov
No data to report?
coverage xmland states that there were no
coverage combinebefore running Codecov.
coveragepyto handle this by calling
coverage xmlin the uploader.
Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending
-tto you where you upload reports.
Cobertura reports can expire - Codecov will reject reports that are older than 12 hours. The logs contain details if a report expired.