Search code examples
pythonunit-testingcode-coveragecoveralls

Why coveralls does report the function or methods as not covered when body is covered?


Why coveralls does report the function or methods as not covered when body is covered?

Take a look at https://coveralls.io/files/431523503#L433 -- the entire body is covered but the method is not marked as covered.

I checked coverage on another project, JavaScript and it seems that it works for these so I suspect this is a bug, of Coverage or the configuration.

Update: I am starting to believe this is not a problem of Coveralls but a problem of pytest-cov because even the generated coverage.xml seems to mark member definitions and comments as not covered in PyCharm (see line 226, no reason to consider it not covered when the full body is covered).

enter image description here


Solution

  • I manage to fix the problem, it was due to the way I was calling coverage, I was importing something from the module before starting coverity.

    Coverage was added at runtime when you did python setup.py test, if the module was present.

    Take a look at https://github.com/pycontribs/jira/blob/master/setup.py - and you will find the trick that I had to implement for loading the version from the module without importing the module.

    Importing a module before starting coverage will get you into cases where coverage is incomplete or not run at all.