coverage report with skip covered: column widths still based on hidden filenames

Issue #524 resolved
Anthony Sottile
created an issue

Ends up with a little silly things like:

py35 runtests: commands[2] | coverage report -m --show-missing --fail-under 100
Name                                                                         Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                        13639      0   1163      0   100%

432 files skipped due to complete coverage.

Comments (6)

  1. Anthony Sottile reporter

    Here's the start of a patch, I'd need to write tests though (and relearn mercurial)

    $ git diff
    diff --git a/coverage/summary.py b/coverage/summary.py
    index b0fa71a..cdd8851 100644
    --- a/coverage/summary.py
    +++ b/coverage/summary.py
    @@ -28,7 +28,16 @@ class SummaryReporter(Reporter):
             file_reporters = self.find_file_reporters(morfs)
    
             # Prepare the formatting strings, header, and column sorting.
    -        max_name = max([len(fr.relative_filename()) for fr in file_reporters] + [5])
    +        max_name = max(
    +            [5] + [
    +                len(fr.relative_filename())
    +                for fr in file_reporters
    +                if not (
    +                    self.config.skip_covered and
    +                    self.coverage._analyze(fr).numbers.n_missing == 0
    +                )
    +            ]
    +        )
             fmt_name = u"%%- %ds  " % max_name
             fmt_err = u"%s   %s: %s"
             fmt_skip_covered = u"\n%s file%s skipped due to complete coverage."
    
    $ coverage report --include="a_really*,test.py"
    Name                                                                                              Stmts   Miss  Cover
    ---------------------------------------------------------------------------------------------------------------------
    a_really_really_really_really_really_really_really_really_really_really_really_long_filename.py       2      0   100%
    test.py                                                                                               4      1    75%
    ---------------------------------------------------------------------------------------------------------------------
    TOTAL                                                                                                 6      1    83%
    
    $ coverage report --include="a_really*,test.py" --skip-cov
    Name      Stmts   Miss  Cover
    -----------------------------
    test.py       4      1    75%
    -----------------------------
    TOTAL         6      1    83%
    
    1 file skipped due to complete coverage.
    
  2. Anthony Sottile reporter

    Ah lol I totally forgot about this patch. Yeah I have yet to write tests for it -- looking at my working directory I had just gotten to the point where I was frustrated with mercurial and gave up.

  3. Log in to comment