diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 22:14:57 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 22:14:57 -0500 |
commit | 3f43a51c7a1e4532d57dc3cd95fa6c4397c87f50 (patch) | |
tree | 9bef9e74ff78aa250f4f3ca230eaad5d3a9b0c26 | |
parent | 76aa3fbcb1592ac4b83363cee8e17094ed3c508f (diff) | |
download | python-coveragepy-git-3f43a51c7a1e4532d57dc3cd95fa6c4397c87f50.tar.gz |
Reports now emphasize missed lines over executed lines, since those are more helpful for directing developers to improved test coverage.
-rw-r--r-- | CHANGES.txt | 5 | ||||
-rw-r--r-- | coverage/htmlfiles/index.html | 12 | ||||
-rw-r--r-- | coverage/htmlfiles/pyfile.html | 2 | ||||
-rw-r--r-- | coverage/summary.py | 12 | ||||
-rw-r--r-- | test/farm/run/run_xxx.py | 2 | ||||
-rw-r--r-- | test/test_api.py | 10 | ||||
-rw-r--r-- | test/test_coverage.py | 12 | ||||
-rw-r--r-- | test/test_process.py | 4 | ||||
-rw-r--r-- | test/test_summary.py | 30 |
9 files changed, 47 insertions, 42 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 6a8cf844..098740f2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,11 @@ Change history for Coverage.py Next version ------------ +- Reports now have a column of missed line counts rather than executed line + counts, since developers should focus on reducing the missed lines to zero, + rather than increasing the executed lines to varying targets. Once + suggested, this seemed blindingly obvious. + - Source files with DOS line endings are now properly tokenized for syntax coloring on non-DOS machines. Fixes `issue 53`_. diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index 700ff8bb..9b8214ff 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -28,11 +28,11 @@ <tr class='tablehead' title='Click to sort'> <th class='name left headerSortDown'>Module</th> <th>statements</th> - <th>run</th> + <th>missing</th> <th>excluded</th> {% if arcs %} <th>branches</th> - <th>br exec</th> + <th>partial</th> {% endif %} <th class='right'>coverage</th> </tr> @@ -42,11 +42,11 @@ <tr class='total'> <td class='name left'>Total</td> <td>{{totals.n_statements}}</td> - <td>{{totals.n_executed}}</td> + <td>{{totals.n_missing}}</td> <td>{{totals.n_excluded}}</td> {% if arcs %} <td>{{totals.n_branches}}</td> - <td>{{totals.n_executed_branches}}</td> + <td>{{totals.n_missing_branches}}</td> {% endif %} <td class='right'>{{totals.pc_covered|format_pct}}%</td> </tr> @@ -56,11 +56,11 @@ <tr class='file'> <td class='name left'><a href='{{file.html_filename}}'>{{file.cu.name}}</a></td> <td>{{file.nums.n_statements}}</td> - <td>{{file.nums.n_executed}}</td> + <td>{{file.nums.n_missing}}</td> <td>{{file.nums.n_excluded}}</td> {% if arcs %} <td>{{file.nums.n_branches}}</td> - <td>{{file.nums.n_executed_branches}}</td> + <td>{{file.nums.n_missing_branches}}</td> {% endif %} <td class='right'>{{file.nums.pc_covered|format_pct}}%</td> </tr> diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index ec69556d..209887b7 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -17,8 +17,8 @@ <h2 class='stats'> {{nums.n_statements}} statements <span class='{{c_run}}' onclick='toggle_lines(this, "run")'>{{nums.n_executed}} run</span> - <span class='{{c_exc}}' onclick='toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span> <span class='{{c_mis}}' onclick='toggle_lines(this, "mis")'>{{nums.n_missing}} missing</span> + <span class='{{c_exc}}' onclick='toggle_lines(this, "exc")'>{{nums.n_excluded}} excluded</span> {% if arcs %} <span class='{{c_par}}' onclick='toggle_lines(this, "par")'>{{n_par}} partial</span> {% endif %} diff --git a/coverage/summary.py b/coverage/summary.py index 3db7b767..7348acab 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -23,10 +23,10 @@ class SummaryReporter(Reporter): max_name = max([len(cu.name) for cu in self.code_units] + [5]) fmt_name = "%%- %ds " % max_name fmt_err = "%s %s: %s\n" - header = (fmt_name % "Name") + " Stmts Exec" + header = (fmt_name % "Name") + " Stmts Miss" fmt_coverage = fmt_name + "%6d %6d" if self.branches: - header += " Branch BrExec" + header += " Branch BrPart" fmt_coverage += " %6d %6d" header += " Cover" fmt_coverage += " %5d%%" @@ -50,9 +50,9 @@ class SummaryReporter(Reporter): try: analysis = self.coverage._analyze(cu) nums = analysis.numbers - args = (cu.name, nums.n_statements, nums.n_executed) + args = (cu.name, nums.n_statements, nums.n_missing) if self.branches: - args += (nums.n_branches, nums.n_executed_branches) + args += (nums.n_branches, nums.n_missing_branches) args += (nums.pc_covered,) if self.show_missing: args += (analysis.missing_formatted(),) @@ -67,9 +67,9 @@ class SummaryReporter(Reporter): if total.n_files > 1: outfile.write(rule) - args = ("TOTAL", total.n_statements, total.n_executed) + args = ("TOTAL", total.n_statements, total.n_missing) if self.branches: - args += (total.n_branches, total.n_executed_branches) + args += (total.n_branches, total.n_missing_branches) args += (total.pc_covered,) if self.show_missing: args += ("",) diff --git a/test/farm/run/run_xxx.py b/test/farm/run/run_xxx.py index 3c39f0f7..27967a9f 100644 --- a/test/farm/run/run_xxx.py +++ b/test/farm/run/run_xxx.py @@ -6,7 +6,7 @@ run(""" contains("out/stdout.txt", "xxx: 3 4 0 7", "\nxxx ", # The reporting line for xxx - " 7 6 85%" # The reporting data for xxx + " 7 1 85%" # The reporting data for xxx ) doesnt_contain("out/stdout.txt", "No such file or directory") clean("out") diff --git a/test/test_api.py b/test/test_api.py index 1f0ad838..4c491366 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -59,9 +59,9 @@ class ApiTest(CoverageTest): self.doReportWork("mycode2") coverage.report(["mycode2.py"]) self.assertEqual(self.stdout(), textwrap.dedent("""\ - Name Stmts Exec Cover Missing + Name Stmts Miss Cover Missing --------------------------------------- - mycode2 7 4 57% 4-6 + mycode2 7 3 57% 4-6 """)) def testReportFile(self): @@ -71,9 +71,9 @@ class ApiTest(CoverageTest): coverage.report(["mycode3.py"], file=fout) self.assertEqual(self.stdout(), "") self.assertEqual(fout.getvalue(), textwrap.dedent("""\ - Name Stmts Exec Cover Missing + Name Stmts Miss Cover Missing --------------------------------------- - mycode3 7 4 57% 4-6 + mycode3 7 3 57% 4-6 """)) def testReportDefault(self): @@ -81,7 +81,7 @@ class ApiTest(CoverageTest): self.doReportWork("mycode4") coverage.report() rpt = re.sub(r"\s+", " ", self.stdout()) - self.assertTrue("mycode4 7 4 57% 4-6" in rpt) + self.assertTrue("mycode4 7 3 57% 4-6" in rpt) def testUnexecutedFile(self): cov = coverage.coverage() diff --git a/test/test_coverage.py b/test/test_coverage.py index e0afd31b..0040e97b 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -104,7 +104,7 @@ class BasicCoverageTest(CoverageTest): # Nothing here d = 6 """, - [1,2,4,6], report="4 4 100%") + [1,2,4,6], report="4 0 100%") def testIndentationWackiness(self): # Partial final lines are OK. @@ -632,7 +632,7 @@ class CompoundStatementTest(CoverageTest): z = 7 assert x == 3 """, - [1,2,3,4,5,7,8], "4-7", report="7 4 57% 4-7") + [1,2,3,4,5,7,8], "4-7", report="7 3 57% 4-7") self.check_coverage("""\ a = 1; b = 2; c = 3; if a != 1: @@ -643,7 +643,7 @@ class CompoundStatementTest(CoverageTest): z = 7 assert y == 5 """, - [1,2,3,4,5,7,8], "3, 7", report="7 5 71% 3, 7") + [1,2,3,4,5,7,8], "3, 7", report="7 2 71% 3, 7") self.check_coverage("""\ a = 1; b = 2; c = 3; if a != 1: @@ -654,7 +654,7 @@ class CompoundStatementTest(CoverageTest): z = 7 assert z == 7 """, - [1,2,3,4,5,7,8], "3, 5", report="7 5 71% 3, 5") + [1,2,3,4,5,7,8], "3, 5", report="7 2 71% 3, 5") def testElifNoElse(self): self.check_coverage("""\ @@ -665,7 +665,7 @@ class CompoundStatementTest(CoverageTest): y = 5 assert x == 3 """, - [1,2,3,4,5,6], "4-5", report="6 4 66% 4-5") + [1,2,3,4,5,6], "4-5", report="6 2 66% 4-5") self.check_coverage("""\ a = 1; b = 2; c = 3; if a != 1: @@ -674,7 +674,7 @@ class CompoundStatementTest(CoverageTest): y = 5 assert y == 5 """, - [1,2,3,4,5,6], "3", report="6 5 83% 3") + [1,2,3,4,5,6], "3", report="6 1 83% 3") def testElifBizarre(self): self.check_coverage("""\ diff --git a/test/test_process.py b/test/test_process.py index ce98a383..e8e8c8be 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -123,9 +123,9 @@ class ProcessTest(CoverageTest): # Reporting should still work even with the .rc file out = self.run_command("coverage report") self.assertMultiLineEqual(out, textwrap.dedent("""\ - Name Stmts Exec Cover + Name Stmts Miss Cover ---------------------------- - b_or_c 7 7 100% + b_or_c 7 0 100% """)) def test_missing_source_file(self): diff --git a/test/test_summary.py b/test/test_summary.py index d2f40aeb..b41a3e7d 100644 --- a/test/test_summary.py +++ b/test/test_summary.py @@ -38,35 +38,35 @@ class SummaryTest(CoverageTest): self.assertEqual(out, 'done\n') report = self.report_from_command("coverage -r") - # Name Stmts Exec Cover + # Name Stmts Miss Cover # --------------------------------------------------------------------- - # c:/ned/coverage/trunk/test/modules/covmod1 2 2 100% - # c:/ned/coverage/trunk/test/zipmods.zip/covmodzip1 2 2 100% - # mycode 4 4 100% + # c:/ned/coverage/trunk/test/modules/covmod1 2 0 100% + # c:/ned/coverage/trunk/test/zipmods.zip/covmodzip1 2 0 100% + # mycode 4 0 100% # --------------------------------------------------------------------- - # TOTAL 8 8 100% + # TOTAL 8 0 100% self.assertFalse("/coverage/__init__/" in report) self.assertTrue("/test/modules/covmod1 " in report) self.assertTrue("/test/zipmods.zip/covmodzip1 " in report) self.assertTrue("mycode " in report) - self.assertEqual(self.last_line_squeezed(report), "TOTAL 8 8 100%") + self.assertEqual(self.last_line_squeezed(report), "TOTAL 8 0 100%") def test_report_just_one(self): # Try reporting just one module self.run_command("coverage -x mycode.py") report = self.report_from_command("coverage -r mycode.py") - # Name Stmts Exec Cover + # Name Stmts Miss Cover # ---------------------------- - # mycode 4 4 100% + # mycode 4 0 100% self.assertEqual(self.line_count(report), 3) self.assertFalse("/coverage/" in report) self.assertFalse("/test/modules/covmod1 " in report) self.assertFalse("/test/zipmods.zip/covmodzip1 " in report) self.assertTrue("mycode " in report) - self.assertEqual(self.last_line_squeezed(report), "mycode 4 4 100%") + self.assertEqual(self.last_line_squeezed(report), "mycode 4 0 100%") def test_report_omitting(self): # Try reporting while omitting some modules @@ -74,16 +74,16 @@ class SummaryTest(CoverageTest): self.run_command("coverage -x mycode.py") report = self.report_from_command("coverage -r -o %s" % prefix) - # Name Stmts Exec Cover + # Name Stmts Miss Cover # ---------------------------- - # mycode 4 4 100% + # mycode 4 0 100% self.assertEqual(self.line_count(report), 3) self.assertFalse("/coverage/" in report) self.assertFalse("/test/modules/covmod1 " in report) self.assertFalse("/test/zipmods.zip/covmodzip1 " in report) self.assertTrue("mycode " in report) - self.assertEqual(self.last_line_squeezed(report), "mycode 4 4 100%") + self.assertEqual(self.last_line_squeezed(report), "mycode 4 0 100%") def test_report_branches(self): self.make_file("mybranch.py", """\ @@ -97,11 +97,11 @@ class SummaryTest(CoverageTest): self.assertEqual(out, 'x\n') report = self.report_from_command("coverage report") - # Name Stmts Exec Branch BrExec Cover + # Name Stmts Miss Branch BrPart Cover # -------------------------------------------- - # mybranch 5 5 2 1 85% + # mybranch 5 0 2 1 85% self.assertEqual(self.line_count(report), 3) self.assertTrue("mybranch " in report) self.assertEqual(self.last_line_squeezed(report), - "mybranch 5 5 2 1 85%") + "mybranch 5 0 2 1 85%") |