[Twisted-Python] Coverage exceptions

Jean-Paul Calderone exarkun at twistedmatrix.com
Thu Jun 30 05:13:52 MDT 2016


On Thu, Jun 30, 2016 at 6:43 AM, Adi Roiban <adi at roiban.ro> wrote:

> Hi,
>
> Recently we have introduced a hard check of 100% coverage for all changes.
> This is done via coverage + codecov + github protected branches.
>
> Now, if your patch is not 100% covered github will not let you merge it.
>
> See for example this change:
> https://github.com/twisted/twisted/pull/261/files#diff-0fea8a8ca713deb7ea6a10053273319aR2360
>
> The errback is there to help with test failures ... but the test should
> never fail, so that errback is never called... and that line is not covered.
>
>
It doesn't always make sense to require 100% execution of all test code.
It's not at all uncommon to only have code in a test suite that runs when a
test fails.  Historically, Twisted has never had a requirement of 100%
execution of test code.  The only test suite coverage requirements that
have commonly been requested or enforced is for coverage of implementation
code.

I'd suggest removing the coverage enforcement for test suite code.


> How should we proceed with these changes?
>
> Maybe this is not the best example and that code could be refactored...
> but I think that the topic of ignoring missing coverage is still valid.
>
> I suggest to introduce `  # pragma: no cover`
>
> and update the coverage config with
>
> [report]
> exclude_lines =
>     pragma: no cover
>
>
This seems like the wrong solution to me.  It forces contributors to do
extra work to mark their test code as an exception *and* provides a
mechanism for incorrectly bypassing the check by using a no-cover pragma in
implementation code.

Jean-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20160630/4f9e5eab/attachment-0002.html>


More information about the Twisted-Python mailing list