Skip to content

Commit

Permalink
fix: make a combine error message clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jun 12, 2024
1 parent d191d10 commit 562e759
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ upgrading your version of coverage.py.
Unreleased
----------

Nothing yet.
- If you attempt to combine statement coverage data with branch coverage data,
coverage.py used to fail with the message "Can't combine arc data with line
data" or its reverse, "Can't combine line data with arc data." These
messages used internal terminology, making it hard for people to understand
the problem. They are now changed to mention "branch coverage data" and
"statement coverage data."


.. scriv-start-here
Expand Down
4 changes: 2 additions & 2 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ def update(
getattr(other_data, "_filename", "???"),
))
if self._has_lines and other_data._has_arcs:
raise DataError("Can't combine arc data with line data")
raise DataError("Can't combine branch coverage data with statement data")
if self._has_arcs and other_data._has_lines:
raise DataError("Can't combine line data with arc data")
raise DataError("Can't combine statement coverage data with branch data")

map_path = map_path or (lambda p: p)

Expand Down
6 changes: 4 additions & 2 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@ def test_update_cant_mix_lines_and_arcs(self) -> None:
covdata2 = DebugCoverageData(suffix='2')
covdata2.add_arcs(ARCS_3)

with pytest.raises(DataError, match="Can't combine arc data with line data"):
msg = "Can't combine branch coverage data with statement data"
with pytest.raises(DataError, match=msg):
covdata1.update(covdata2)

with pytest.raises(DataError, match="Can't combine line data with arc data"):
msg = "Can't combine statement coverage data with branch data"
with pytest.raises(DataError, match=msg):
covdata2.update(covdata1)

def test_update_file_tracers(self) -> None:
Expand Down

0 comments on commit 562e759

Please sign in to comment.