Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nedbat opened this issue Oct 5, 2016 · 6 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Oct 5, 2016

Originally reported by Anthony Sottile (Bitbucket: asottile, GitHub: asottile)


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.

@nedbat
Copy link
Owner Author

nedbat commented Oct 5, 2016

Original comment by Anthony Sottile (Bitbucket: asottile, GitHub: asottile)


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 (bb)](https://bitbucket.org/ned/coveragepy/commits/b0fa71a)..cdd8851 [100644 (bb)](https://bitbucket.org/ned/coveragepy/commits/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.

@nedbat
Copy link
Owner Author

nedbat commented Dec 12, 2016

Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary)


I'll write the tests for your fine patch, unless you already did ?

@nedbat
Copy link
Owner Author

nedbat commented Dec 12, 2016

Original comment by Anthony Sottile (Bitbucket: asottile, GitHub: asottile)


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.

@nedbat
Copy link
Owner Author

nedbat commented Dec 12, 2016

Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary)


@asottile here it is : https://bitbucket.org/ned/coveragepy/pull-requests/98/report-must-ignore-skipped-files-524/diff . Would you have time to review it ?

@nedbat
Copy link
Owner Author

nedbat commented Dec 14, 2016

Fixed in 6d6ddf50dd7f (bb), thanks Loïc!

@nedbat
Copy link
Owner Author

nedbat commented Dec 27, 2016

This fix was released as part of Coverage.py 4.3.

@nedbat nedbat closed this as completed Dec 27, 2016
@nedbat nedbat added minor bug Something isn't working labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant