[TIP] Finding redundant pragma: no cover instances

Ned Batchelder ned at nedbatchelder.com
Thu Apr 5 04:24:11 PDT 2018


On 4/5/18 6:44 AM, Gordon Wrigley wrote:
> Hi
>
> Is there an easy way to find pragma: no cover instances that aren't 
> actually required. Aka ones that actually are covered? I have a code 
> base with a bunch of these in and it'd be nice to slowly remove them, 
> the first step in that is figuring out which of the current ones are 
> actually necessary and which are historical.

There isn't a built-in feature to do this, but there's a way: edit your 
.coveragerc file (or create one), and define a new pragma pattern (with 
[report] exclude_lines), so that your existing "no cover" pragmas aren't 
recognized.  Then run coverage again.  You can see how coverage is 
reported for your "no cover" lines, and decide what to do about each 
one.  Then put back your original .coveragerc file.

--Ned.
>
> Regards G
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180405/59e37a53/attachment.htm>


More information about the testing-in-python mailing list