From 562e7593673d7e33e76d1eb7b22c3f0ad6fa3dfd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 12 Jun 2024 16:10:25 -0400 Subject: [PATCH] fix: make a combine error message clearer --- CHANGES.rst | 7 ++++++- coverage/sqldata.py | 4 ++-- tests/test_data.py | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index bb8648d40..b1bc394dc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/coverage/sqldata.py b/coverage/sqldata.py index e84855171..e739c39c3 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -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) diff --git a/tests/test_data.py b/tests/test_data.py index 1f0bb20dc..144c145d9 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -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: