summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-04-18 17:33:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-04-18 17:33:03 -0400
commit2c00b87b47d164ecd67de21df8caa38cd9b681ab (patch)
tree3f983ceaa970a032693a3b5d20b4421888e66f7d
parentfecf20ef16651d48f9221e77f7a57de7a37b1658 (diff)
downloadpython-coveragepy-2c00b87b47d164ecd67de21df8caa38cd9b681ab.tar.gz
Use ->exit for missed branches in the textual report. #469
-rw-r--r--CHANGES.rst5
-rw-r--r--coverage/results.py2
-rw-r--r--tests/test_summary.py5
3 files changed, 8 insertions, 4 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 222a63e..3873d29 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -30,11 +30,16 @@ Unreleased
indents was fixed. The index page also has slightly different styling, to
try to make the clickable detail pages more apparent.
+- Missing branches reported with ``coverage report -m`` will now say ``->exit``
+ for missed branches to the exit of a function, rather than a negative number.
+ Fixes `issue 469`_.
+
- ``coverage --help`` and ``coverage --version`` now mention which tracer is
installed, to help diagnose problems. The docs mention which features need
the C extension. (`issue 479`_)
.. _issue 440: https://bitbucket.org/ned/coveragepy/issues/440/yielded-twisted-failure-marked-as-missed
+.. _issue 469: https://bitbucket.org/ned/coveragepy/issues/469/strange-1-line-number-in-branch-coverage
.. _issue 472: https://bitbucket.org/ned/coveragepy/issues/472/html-report-indents-incorrectly-for-one
.. _issue 475: https://bitbucket.org/ned/coveragepy/issues/475/generator-expression-is-marked-as-not
.. _issue 479: https://bitbucket.org/ned/coveragepy/issues/479/clarify-the-need-for-the-c-extension
diff --git a/coverage/results.py b/coverage/results.py
index dc93f3f..7853848 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -96,7 +96,7 @@ class Analysis(object):
for line, exits in line_exits:
for ex in sorted(exits):
if line not in missing:
- pairs.append('%d->%d' % (line, ex))
+ pairs.append("%d->%s" % (line, (ex if ex > 0 else "exit")))
return ', '.join(pairs)
def arcs_unpredicted(self):
diff --git a/tests/test_summary.py b/tests/test_summary.py
index 89a8443..681e204 100644
--- a/tests/test_summary.py
+++ b/tests/test_summary.py
@@ -182,7 +182,6 @@ class SummaryTest(CoverageTest):
print("x")
if y:
print("y")
- return x
branch(1, 1)
""")
out = self.run_command("coverage run --branch mybranch.py")
@@ -191,11 +190,11 @@ class SummaryTest(CoverageTest):
# Name Stmts Miss Branch BrPart Cover Missing
# ----------------------------------------------------------
- # mybranch.py 7 0 4 2 82% 2->4, 4->6
+ # mybranch.py 6 0 4 2 80% 2->4, 4->exit
self.assertEqual(self.line_count(report), 3)
self.assertIn("mybranch.py ", report)
- self.assertEqual(self.last_line_squeezed(report), "mybranch.py 7 0 4 2 82% 2->4, 4->6")
+ self.assertEqual(self.last_line_squeezed(report), "mybranch.py 6 0 4 2 80% 2->4, 4->exit")
def test_report_show_missing_branches_and_lines(self):
self.make_file("main.py", """\