1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #127 invalid

Difference in running coverage vs coverage as a plugin

Alfredo Deza
created an issue

Hi Ned,

I have recently implemented coverage to provide your awesome tool to people who use konira.

The issue I am experiencing is that coverage running as a plugin is not reporting the same numbers compared to running coverage itself.

What is odd is that coverage as a konira add-on, reports coverage for lines in a method but not the method line itself (?).

The coverage implementation for konira [1] borrows most of the code from the pytest-coverage plugin (as I knew this was a working approach).

I am following your documentation to enable and run coverage along with konira, calling coverage.start() before the tests are run and then create the report.

To replicate this problem with konira's own tests:

{{{ konira -d cover }}} vs {{{ coverage run which konira -d && coverage report -i --include='*' }}}

If you clone the konira repository [2] and install it in a virtualenv and run the above commands you should be able to see the difference.

I am not expecting you to debug my code :) But I think I am doing things correctly and I might be hitting a bug here. Any help is greatly appreciated.

[0] http://konira.cafepais.com

[1] https://github.com/alfredodeza/konira/blob/master/konira/ext/cover.py

[2] https://github.com/alfredodeza/konira

Comments (3)

  1. eduardo schettino

    What is odd is that coverage as a konira add-on, reports coverage for lines in a method but not the method line itself (?).

    I guess you need to start coverage before importing the modules under coverage.

  2. Alfredo Deza reporter

    Thanks for replying so fast to my report.

    The problem was, as you both well pointed out, that modules were imported *before* the tests were run.

    Moreover, my issue became apparent because I was trying to run coverage on the test runner itself, so it is impossible to import modules after coverage has started :) How meta!

    This is perfectly fine as I was more worried in user-cases where they might experience the same issue. I have tested a few other modules and no such thing as different coverage numbers are triggered.

    Again, thanks for responding so fast and helping me figure it out!

  3. Log in to comment