diff options
author | reybog90 <reybog90@o2.pl> | 2019-10-30 20:04:20 +0100 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-01 06:36:13 -0400 |
commit | 9b11268c358040abf7384702c3bc0e863ab753c5 (patch) | |
tree | e657af6f7eb583354f41c455bee639aaaf9a39fa /coverage/summary.py | |
parent | 49e06d33ea63d8e3e44ab5b69d713783551dfaa9 (diff) | |
download | python-coveragepy-git-9b11268c358040abf7384702c3bc0e863ab753c5.tar.gz |
Optionally skip empty files in reports
Diffstat (limited to 'coverage/summary.py')
-rw-r--r-- | coverage/summary.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/coverage/summary.py b/coverage/summary.py index 08c8a947..97d9fff0 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -21,6 +21,7 @@ class SummaryReporter(object): self.outfile = None self.fr_analysis = [] self.skipped_count = 0 + self.empty_count = 0 self.total = Numbers() self.fmt_err = u"%s %s: %s" @@ -48,6 +49,7 @@ class SummaryReporter(object): max_name = max([len(fr.relative_filename()) for (fr, analysis) in self.fr_analysis] + [5]) fmt_name = u"%%- %ds " % max_name fmt_skip_covered = u"\n%s file%s skipped due to complete coverage." + fmt_skip_empty = u"\n%s empty file%s skipped." header = (fmt_name % "Name") + u" Stmts Miss" fmt_coverage = fmt_name + u"%6d %6d" @@ -129,6 +131,10 @@ class SummaryReporter(object): self.writeout( fmt_skip_covered % (self.skipped_count, 's' if self.skipped_count > 1 else '') ) + if self.config.skip_empty and self.empty_count: + self.writeout( + fmt_skip_empty % (self.empty_count, 's' if self.empty_count > 1 else '') + ) return self.total.n_statements and self.total.pc_covered @@ -142,5 +148,8 @@ class SummaryReporter(object): if self.config.skip_covered and no_missing_lines and no_missing_branches: # Don't report on 100% files. self.skipped_count += 1 + elif self.config.skip_empty and nums.n_statements == 0: + # Don't report on empty files. + self.empty_count += 1 else: self.fr_analysis.append((fr, analysis)) |