Skip to content

Commit 01cf50c

Browse files
committed
test: add a test to satisfy a condition in results.py
1 parent 74d3c50 commit 01cf50c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

coverage/results.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ def missing_branch_arcs(self) -> dict[TLineNo, list[TLineNo]]:
202202
branch_lines = set(self._branch_lines())
203203
mba = collections.defaultdict(list)
204204
for l1, l2 in missing:
205-
if l1 == l2:
206-
continue
205+
assert l1 != l2, f"In {self.filename}, didn't expect {l1} == {l2}"
207206
if l1 in branch_lines:
208207
mba[l1].append(l2)
209208
return mba

tests/test_json.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,3 +559,20 @@ def test_context_non_relative(self) -> None:
559559

560560
def test_context_relative(self) -> None:
561561
self.run_context_test(relative_files=True)
562+
563+
def test_l1_equals_l2(self) -> None:
564+
# In results.py, we had a line checking `if l1 == l2` that was never
565+
# true. This test makes it true. The annotations are essential, I
566+
# don't know why.
567+
self.make_file("wtf.py", """\
568+
def function(
569+
x: int,
570+
y: int,
571+
) -> None:
572+
return x + y
573+
574+
assert function(3, 5) == 8
575+
""")
576+
cov = coverage.Coverage(branch=True)
577+
mod = self.start_import_stop(cov, "wtf")
578+
cov.json_report(mod)

0 commit comments

Comments
 (0)