Hi y’all. I am having an issue with Python coverag...
# general
i
Hi y’all. I am having an issue with Python coverage. I am trying the use the raw coverage report in another tool, but even though the console report and the JSON report are both correct and show the correct coverage, the raw report (
dist/coverage/python/.coverage
) shows 0 lines covered. It looks like this was discussed last year [here](https://pantsbuild.slack.com/archives/C046T6T9U/p1651563909792529) with a minimal [repo](https://github.com/dbari/pants_coverage) reproducing the issue (it is described as issue 2). I can reproduce the issue with that repo on Pants 2.16. Does anyone know why the raw
.coverage
report is incorrect or what I could do to fix it? Thanks!
The author of the other issue seems to have solved their problem by not needing the raw
.coverage
report, however I do need it (or will need to modify our tools to not need it somehow)
h
Hmm, coverage is complicated in the Pants world because of incremental testing and sandboxing - a given pytest run only sees a subset of the code and tests, and so coverage data has to be combined to make global sense.
That said, if the console and JSON reports are correct, that part is being handled OK it sounds like.
So this is just an issue with the raw report
This will require some digging
A good start is to run with
pants --keep-sandboxes=always
, and then look inside the relevant process sandboxes (whose paths will be logged to the console). Relevant would be the
pytest
run, of course, and also any processes that merge or generate coverage reports. The
__run.sh
script in each sandbox will show what the exact command was, and the input and output files will be in the sandbox for inspection.
👍 1
i
Thanks. We have decided to modify our tool to use the json coverage report, but I’ll dig around and see if I can figure out why the raw report isn’t correct
h
That would be great, thanks! It may be something trivial