Skip to content

Commit

Permalink
test: add a test to satisfy a condition in results.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Nov 24, 2024
1 parent 74d3c50 commit 01cf50c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions coverage/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def missing_branch_arcs(self) -> dict[TLineNo, list[TLineNo]]:
branch_lines = set(self._branch_lines())
mba = collections.defaultdict(list)
for l1, l2 in missing:
if l1 == l2:
continue
assert l1 != l2, f"In {self.filename}, didn't expect {l1} == {l2}"
if l1 in branch_lines:
mba[l1].append(l2)
return mba
Expand Down
17 changes: 17 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,20 @@ def test_context_non_relative(self) -> None:

def test_context_relative(self) -> None:
self.run_context_test(relative_files=True)

def test_l1_equals_l2(self) -> None:
# In results.py, we had a line checking `if l1 == l2` that was never
# true. This test makes it true. The annotations are essential, I
# don't know why.
self.make_file("wtf.py", """\
def function(
x: int,
y: int,
) -> None:
return x + y
assert function(3, 5) == 8
""")
cov = coverage.Coverage(branch=True)
mod = self.start_import_stop(cov, "wtf")
cov.json_report(mod)

0 comments on commit 01cf50c

Please sign in to comment.