Python `coverage run` get lower coverage rate in travis than local

If I run coverage run -a locally, the coverage looks normal.
but it is close to 0% coverage in travis, only the was covered!
this is an travis build link
I have added a coverage report after the coverage run commands.
There is another coverage report after the pytest, which looks good.

this is the corresponding travis yaml file

If I run coverage run -a locally, the coverage looks normal.

you can accumulate data across runs with the -a flag on the run command.

So the “normal” data you see locally is not for the specific run but accumulated data.

Thank you for the fast reply!

I tried to remove the -a, the coverage is normal (much larger than 0%) locally.

Well, then look for any other differences. Or, better, get diagnostic output from the commands you run at Travis to find out what they are doing and where they are going wrong.

E.g. if fewer tests than expected are begin executed, get a full list of tests rather than just the coverage report. That will show if they are not discovered at all or are skipped for some reason. Then you’ll know where to dig next…

Problem diagnostic is always done by the same algorithm:

  • Find the exact place where the problem manifests itself
  • Examine the state of the system at that moment to find out which of the values are wrong
  • Trace the wrong value back to its origin