[TIP] Getting covered lines using python-coverage

ThanhVu (Vu) Nguyen nguyenthanhvuh at gmail.com
Sat Feb 20 12:10:42 PST 2016

Hi Ned, thanks for the quick reply.   I am using your tool for my research,
which tries to determine how different program runs produce different
coverage (e.g., when a program runs with option -a  it covers line 1,2  ,
and when runs with option -b it covers line 1,4).  Thus I want to get the
covered lines.

Yes I realize the xml file does include those information but I would have
to parse it.  So I thought if python-coverage already has something that
can output those then I don't have to parse the xml file.

I do use the --pylib (more specifically I have cover_pylib = True in the
.coveragerc). It does capture the coverage for stdlib files as expected,
and python-coverage report works fine. However the annotate command doesn't
seem to write the filename,cover files corresponding to the stdlib files.


On Sat, Feb 20, 2016 at 2:58 PM, Ned Batchelder <ned at nedbatchelder.com>

> Vu,
> This is an interesting question :)  If you don't mind me asking, why do
> you want the covered lines, and why don't the existing reports suit your
> need?  The XML report is the most machine-readable, you might find that
> easier than dealing with the annotated files.
> The standard library isn't covered unless you ask for it with the --pylib
> switch on "run".
> --Ned.
> On 2/20/16 2:43 PM, ThanhVu (Vu) Nguyen wrote:
> Hi, I am wondering how to get the covered lines using python-coverage ?
> Running python-coverage report -m  gives you the uncovered/missed lines.
>  is there a similar option that gives the covered lines ?
> Currently to get the covered lines I use python-coverage annotate and go
> through each of the filename,cover  source file and parse for those with
> prefix ">"  .   But this method of using annotate doesn't work for standard
> library, it generates no filename,cover files.   Is this a known issue ?
> any work around ?
> Thanks,
> Vu
> _______________________________________________
> testing-in-python mailing listtesting-in-python at lists.idyll.orghttp://lists.idyll.org/listinfo/testing-in-python
> _______________________________________________
> 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/20160220/cd358f37/attachment.htm>

More information about the testing-in-python mailing list