简体   繁体   中英

Python sub-process coverage on Travis

I've seen a couple of articles on the subject, but none seem to work for me.

The case

A Python package with tests based on unittest , pytest as test runner and plugins like pytest-cov to support the coverage . All works fine locally, all tests are executed and pass, coverage is calculated for all tests, including CLI tests using subprocess.check_output .

The issue

Somehow, on Travis side, coverage is not calculated for the CLI tests. No matter what I do, no matter where and how many times I do include coverage.pth or sitecustomize.py (read more about it here ), coverage for CLI is not included.

The obvious question

What am I doing wrong?

As a recap of what was done to solve it (for the folks that may need the answer) the issue was on my configuration of tox to blame.

Before (did not work well, although tests passed)

[testenv]
# Some other config above this line
commands =
    pytest

After (where I got it really to the 100% covered)

[testenv]
# Some other config above this line
commands =
    coverage erase
    pip install -e .
    pytest

The pip install -e. is obviously the key here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM