Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect coverage report #117

Closed
jgosmann opened this issue May 11, 2016 · 21 comments
Closed

Incorrect coverage report #117

jgosmann opened this issue May 11, 2016 · 21 comments

Comments

@jgosmann
Copy link

Using py.test --cov-config .coveragerc --cov nengo -n 6 nengo a lot of lines that should be hit get reported as missed (like class and function definitions in a module). This might be related to #19 as the project has a conftest file importing other modules from the project.

Using coverage run --rcfile .coveragerc --source nengo -m py.test nengo instead a correct coverage report is generated, but this command does not support xdist.

@ionelmc
Copy link
Member

ionelmc commented May 12, 2016

It might be possible to measure it with a workaround like this: https://github.com/ionelmc/pytest-benchmark/blob/master/tox.ini#L32-L33 - it forces the engine used for subprocess measurements to load early.

adamchainz added a commit to adamchainz/pytest-flake8dir that referenced this issue Jun 22, 2017
Coverage wasn't happening for import/def lines. Looks like pytest-dev/pytest-cov#117 affects us, I guess the plugin load/execute order is what is breaking it for us.
@yunstanford
Copy link

Have this been fixed ? i am still getting this issue.

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Not yet fixed. There is a workaroud tho.

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Show an example and maybe we can figure it out.

@yunstanford
Copy link

you can checkout the last travis ci build of Sanic https://github.com/channelcat/sanic

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Maybe your local checkout is dirty (have any .coverage/.coverage.* files?). Can we narrow it down to something smaller?

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Ah yes, it's a pytest plugin, so plugin loading is currently unpredictable. See pytest-dev/pytest#935

@yunstanford
Copy link

yeah, you're right. i had .coverage files, after git clean -xfd, i can also reproduce locally.

@yunstanford
Copy link

yunstanford commented Aug 10, 2017

How can we fix that ? should we load pytest-cov first ? what step matters actually when running pytest, pytest_configure ?

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Well ... this being a problem in pytest, we can only talk about workarounds here.

@yunstanford
Copy link

yunstanford commented Aug 10, 2017

yeah, any suggestion ? it works fine for me when i use uranium another python build system (https://github.com/yunstanford/pytest-sanic/blob/master/ubuild.py#L16). but it doesn't work with tox.

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Afaik it's either the workaround I use in pytest-benchmark (forceload pytest-cov subprocess engine) or ronny's plugin trick (haven't tried it).

@yunstanford
Copy link

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

@yunstanford
Copy link

yunstanford commented Aug 10, 2017

hmm.. it doesn't work for me by just setting these env.. am i missing anything ? and it shows

None
  Module already imported so can not be re-written: pytest_cov

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

What happens if you run

coverage combine --append
coverage report

@yunstanford
Copy link

Then looks correct.

@ionelmc
Copy link
Member

ionelmc commented Aug 10, 2017

Well there you go, just run coverage combine --append before publishing coverage results.

@yunstanford
Copy link

yeah, but pytest always prints out the incorrect one first. is there any way to disable that ?

@yunstanford
Copy link

nvm, --cov-report=

@ionelmc
Copy link
Member

ionelmc commented Oct 28, 2017

This is fixed right? Also, #177 will clarify the solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants