1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #199 resolved

Add a way to sort the text report

Ned Batchelder
repo owner created an issue

Hi Ned,

The HTML output looks very good, however I’m running the coverage tool on a VMware and just want to mail the output as plain text to my colleagues.

Sending all those HTML files to all of them (or copy them to a server) is too much, so I need another trick - maybe just a python filter that sorts it out.

Thanks for your time!


From: Ned Batchelder [mailto:ned@nedbatchelder.com] Sent: Friday, September 28, 2012 14:56 To: Tillaart, Rob van den Subject: Re: question about coverage tool

Hi Rob,

In the HTML report, you can click on the column headers to sort by the column you're interested in.


On 9/28/2012 7:33 AM, Tillaart, Rob van den wrote:

Hi Ned,

Just new to python development I found the coverage tool which does a good job for Q&A.

Q: is there an option to sort the output on coverage %?

If not I would like to put it on the “wishlist” for next release.

A sorted list makes it easier to see which files needs attention most,

Thanks in advance,

Rob Tillaart


Comments (4)

  1. Ned Batchelder reporter
    Thanks Ned for creating the ticket,
    I made a list of my requirements, made them as generic as possible
    (1) enable sorting on coverage %column  (default seems to be name)
       =>  ideally on any column  [name, statements, miss, coverage]
    (2) ascending sorting (default)
    (3) descending sorting
    (4) remove the lines with 100% coverage from the overview -> show only tests that need attention, useful for big projects to minimize output
    (5) show only topN  lines, eg top 10 or top 20  -> minimizes output
    (6) Total  #files  versus  #files@100%  -> indicator of the fragmentation of the coverage
    Calls could look like:
    Coverage report  --sort=coverage --descending  --no100% ...
    Coverage report  --sort=statements --…
    Coverage report  --sort=miss --no100% ...
    Coverage report  --sort=name --descending   ... 
    Coverage report  --sort=coverage --no100%  --top=15 ...
    Think no short version needed (like –s) as the word sort is already short
    (you might add above to the ticket)
    Thanks again,
  2. bachmann1234

    I took a look into this ticket. The currently implementation does not store coverage numbers. They are computed by the fly.

    It seems expensive to compute and store all this to sort on other properties and this could be better achieved though command line tools or other post processing.

  3. Ned Batchelder reporter

    Control over the sorting column is available in the report:sort option in the .coveragerc. This work is completed in f4001cd0cd52. It doesn't provide the option to sort descending, or to control it from the command line. We'll see if there is interest in adding that support.

  4. Log in to comment