summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst8
-rw-r--r--coverage/summary.py2
-rw-r--r--tests/coveragetest.py9
-rw-r--r--tests/test_summary.py19
4 files changed, 27 insertions, 11 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index fe7fcd60..1e04f222 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,7 +14,12 @@ Version 4.0.1
coverage.py v3.7.1 behavior, which silently ignored unreadable files.
Prompted by `issue 418`_.
-- In 4.0, data files recorded a summary of the system on which it was run.
+- The --skip-covered option would skip reporting on 100% covered files, but
+ also skipped them when calculating total coverage. This was wrong, it should
+ only remove lines from the report, not change the final answer. This is now
+ fixed, closing `issue 423`_.
+
+- In 4.0, the data file recorded a summary of the system on which it was run.
Combined data files would keep all of those summaries. This could lead to
enormous data files consisting of mostly repetitive useless information. That
summary is now gone, fixing `issue 415`_. If you want summary information,
@@ -35,6 +40,7 @@ Version 4.0.1
.. _issue 416: https://bitbucket.org/ned/coveragepy/issues/416/mocking-ospathexists-causes-failures
.. _issue 418: https://bitbucket.org/ned/coveragepy/issues/418/json-parse-error
.. _issue 419: https://bitbucket.org/ned/coveragepy/issues/419/nosource-no-source-for-code-path-to-c
+.. _issue 423: https://bitbucket.org/ned/coveragepy/issues/423/skip_covered-changes-reported-total
Version 4.0 --- 20 September 2015
diff --git a/coverage/summary.py b/coverage/summary.py
index 25bb365e..4dcaa735 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -60,6 +60,7 @@ class SummaryReporter(Reporter):
try:
analysis = self.coverage._analyze(fr)
nums = analysis.numbers
+ total += nums
if self.config.skip_covered:
# Don't report on 100% files.
@@ -83,7 +84,6 @@ class SummaryReporter(Reporter):
missing_fmtd += branches_fmtd
args += (missing_fmtd,)
outfile.write(fmt_coverage % args)
- total += nums
except Exception:
report_it = not self.config.ignore_errors
if report_it:
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 18524758..0e9076cc 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -354,7 +354,8 @@ class CoverageTest(
Compare with `command_line`.
- Returns a pair: the process' exit status and stdout text.
+ Returns a pair: the process' exit status and stdout text, which are
+ also stored as self.last_command_status and self.last_command_output.
"""
# Add our test modules directory to PYTHONPATH. I'm sure there's too
@@ -368,9 +369,9 @@ class CoverageTest(
pypath += testmods + os.pathsep + zipfile
self.set_environ('PYTHONPATH', pypath)
- status, output = run_command(cmd)
- print(output)
- return status, output
+ self.last_command_status, self.last_command_output = run_command(cmd)
+ print(self.last_command_output)
+ return self.last_command_status, self.last_command_output
def report_from_command(self, cmd):
"""Return the report from the `cmd`, with some convenience added."""
diff --git a/tests/test_summary.py b/tests/test_summary.py
index a54d5337..cc6b3204 100644
--- a/tests/test_summary.py
+++ b/tests/test_summary.py
@@ -253,17 +253,22 @@ class SummaryTest(CoverageTest):
""")
out = self.run_command("coverage run main.py")
self.assertEqual(out, "z\n")
- report = self.report_from_command("coverage report --skip-covered")
+ report = self.report_from_command("coverage report --skip-covered --fail-under=70")
# Name Stmts Miss Cover
# ------------------------------------
# not_covered.py 2 1 50%
+ # ------------------------------------
+ # TOTAL 6 1 83%
#
# 1 file skipped due to complete coverage.
- self.assertEqual(self.line_count(report), 5, report)
+ self.assertEqual(self.line_count(report), 7, report)
squeezed = self.squeezed_lines(report)
self.assertEqual(squeezed[2], "not_covered.py 2 1 50%")
+ self.assertEqual(squeezed[4], "TOTAL 6 1 83%")
+ self.assertEqual(squeezed[6], "1 file skipped due to complete coverage.")
+ self.assertEqual(self.last_command_status, 0)
def test_report_skip_covered_branches(self):
self.make_file("main.py", """
@@ -293,12 +298,16 @@ class SummaryTest(CoverageTest):
# Name Stmts Miss Branch BrPart Cover
# --------------------------------------------------
# not_covered.py 4 0 2 1 83%
+ # --------------------------------------------------
+ # TOTAL 13 0 4 1 94%
#
# 2 files skipped due to complete coverage.
- self.assertEqual(self.line_count(report), 5, report)
+ self.assertEqual(self.line_count(report), 7, report)
squeezed = self.squeezed_lines(report)
self.assertEqual(squeezed[2], "not_covered.py 4 0 2 1 83%")
+ self.assertEqual(squeezed[4], "TOTAL 13 0 4 1 94%")
+ self.assertEqual(squeezed[6], "2 files skipped due to complete coverage.")
def test_report_skip_covered_branches_with_totals(self):
self.make_file("main.py", """
@@ -330,7 +339,7 @@ class SummaryTest(CoverageTest):
# also_not_run.py 2 1 0 0 50%
# not_covered.py 4 0 2 1 83%
# --------------------------------------------------
- # TOTAL 6 1 2 1 75%
+ # TOTAL 13 1 4 1 88%
#
# 1 file skipped due to complete coverage.
@@ -338,7 +347,7 @@ class SummaryTest(CoverageTest):
squeezed = self.squeezed_lines(report)
self.assertEqual(squeezed[2], "also_not_run.py 2 1 0 0 50%")
self.assertEqual(squeezed[3], "not_covered.py 4 0 2 1 83%")
- self.assertEqual(squeezed[5], "TOTAL 6 1 2 1 75%")
+ self.assertEqual(squeezed[5], "TOTAL 13 1 4 1 88%")
self.assertEqual(squeezed[7], "1 file skipped due to complete coverage.")
def test_report_skip_covered_all_files_covered(self):