1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #251 new

Report covered 'no-cover' lines

Anonymous created an issue

It is often the case that a feature will be added in one commit, but there isn't any client code that calls a particular method yet. As such, the method is marked

pragma: no cover

coverage passes and everyone continues along their merry way.

Later, when client code is added that exercises that code path, it would be nice if coverage.py could complain saying something like "WARNING: Block marked 'no cover' actually covered. You may want to remove the pragma." That way, we could continually make sure that the minimum amount of code is under 'no cover' pragmas.

Comments (3)

  1. Ned Batchelder repo owner

    Hmm, I'm not sure I approve of pragma'ing away code that you intend to cover eventually, but it's an interesting idea to alert the user to unneeded pragmas.

  2. John Vandenberg

    In my experience, #pragma: no cover is most often used for OS specific paths. These proposed alerts would be a good way to advertise that platform specific code can be properly required when the tests are being run on the respective hosts using env vars https://bitbucket.org/ned/coveragepy/issues/563

    The only complexity is whether this alert is only added for the default #pragma: no cover, in which case you would want to add another default which doesnt trigger the alert, and/or a way to turn off the warning (but imo the ecosystem is improved if the warnings cant be easily disabled, as it is important that coders limit when the block isnt covered to specific conditions).

  3. Log in to comment