summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/html.py10
-rw-r--r--tests/test_html.py9
-rw-r--r--tests/test_parser.py5
3 files changed, 13 insertions, 11 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 5b792c7e..0d6e6f96 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -226,13 +226,13 @@ class HtmlReporter(Reporter):
short_fmt = "%s ↛ %s"
annotate_html = ",   ".join(short_fmt % (lineno, d) for d in shorts)
- annotate_long = "Line %d was executed, but didn't " % lineno
if len(longs) == 1:
- annotate_long += longs[0]
- elif len(longs) == 2:
- annotate_long += longs[0] + " or " + longs[1]
+ annotate_long = longs[0]
else:
- annotate_long += ", ".join(longs[:-1]) + ", or " + longs[-1]
+ annotate_long = "%d missed branches: %s" % (
+ len(longs),
+ ", ".join("%d) %s" % (num, ann_long) for num, ann_long in enumerate(longs, start=1)),
+ )
elif lineno in analysis.statements:
line_class.append(c_run)
diff --git a/tests/test_html.py b/tests/test_html.py
index fda68aeb..67c6d9b6 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -525,15 +525,12 @@ class HtmlGoldTests(CoverageGoldTest):
'<span class="num">3</span>'),
'<span class="pc_cov">70%</span>',
('<span class="annotate short">8&#x202F;&#x219B;&#x202F;11</span>'
- '<span class="annotate long">Line 8 was executed, '
- 'but didn\'t jump to line 11</span>'),
+ '<span class="annotate long">line 8 didn\'t jump to line 11, because the condition on line 8 was never false</span>'),
('<span class="annotate short">17&#x202F;&#x219B;&#x202F;exit</span>'
- '<span class="annotate long">Line 17 was executed, '
- 'but didn\'t exit function "two"</span>'),
+ '<span class="annotate long">line 17 didn\'t return from function \'two\', because the condition on line 17 was never false</span>'),
('<span class="annotate short">25&#x202F;&#x219B;&#x202F;26,&nbsp;&nbsp; '
'25&#x202F;&#x219B;&#x202F;28</span>'
- '<span class="annotate long">Line 25 was executed, '
- 'but didn\'t jump to line 26 or jump to line 28</span'),
+ '<span class="annotate long">2 missed branches: 1) line 25 didn\'t jump to line 26, because the condition on line 25 was never true, 2) line 25 didn\'t jump to line 28, because the condition on line 25 was never false</span>'),
)
contains(
"out/b_branch/index.html",
diff --git a/tests/test_parser.py b/tests/test_parser.py
index fd820b9b..cf433009 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -192,6 +192,7 @@ class ParserMissingArcDescriptionTest(CoverageTest):
run_in_temp_dir = False
def test_missing_arc_description(self):
+ # This code is never run, so the actual values don't matter.
text = textwrap.dedent(u"""\
if x:
print(2)
@@ -216,6 +217,10 @@ class ParserMissingArcDescriptionTest(CoverageTest):
parser.missing_arc_description(6, -5),
"line 6 didn't return from function 'func5', because the loop on line 6 didn't complete"
)
+ self.assertEqual(
+ parser.missing_arc_description(6, 7),
+ "line 6 didn't jump to line 7, because the loop on line 6 never started"
+ )
class ParserFileTest(CoverageTest):