Pytest-coverage combine does not calculates same coverage as the whole test suite

55 views Asked by At

I have a long Python unit test suite that I can run with the following command:

pytest --cov=. tests/unit/

It reports a coverage of 77%. However if I execute the test suite in chunks using pytest-split and then combine the results it gets lower coverage, I am wondering how this behaviour happens? I would expect that both approaches should calculate the same coverage, is my expectation right?

For the sake of the details, here are the commands I use to combine the results:

COVERAGE_FILE=.coverage_1 pytest --cov=. tests/unit/ --splits 2 --group 1
COVERAGE_FILE=.coverage_2 pytest --cov=. tests/unit/ --splits 2 --group 2
coverage combine --keep .coverage_*
coverage report

By the way this is the .coveragerc configuration file:

[run]
omit = tests/*
parallel = True
relative_files = True

Any hint or help is going to be much appreciated.

0

There are 0 answers