summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-02-28 08:28:58 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-02-28 08:28:58 -0500
commit169972546b699f01813131d5356d0edcfc739343 (patch)
tree62a356a51e950dfced5a4db3e8a666ef369c4c0f
parent3f3856702d7e88065dd0e13f022a4d7c69eeaf6b (diff)
downloadpython-coveragepy-git-169972546b699f01813131d5356d0edcfc739343.tar.gz
fix: improve an error message. #803
Fixes #803.
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/sqldata.py4
-rw-r--r--tests/test_data.py6
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 201f1d06..82f174dd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -37,6 +37,10 @@ Unreleased
- It has a little more room for line numbers so that 4-digit numbers work
well, fixing `issue 1124`_.
+- Improved the error message when combining line and branch data, so that users
+ will be more likely to understand what's happening, closing `issue 803`_.
+
+.. _issue 803: https://github.com/nedbat/coveragepy/issues/803
.. _issue 1108: https://github.com/nedbat/coveragepy/issues/1108
.. _pull request 1110: https://github.com/nedbat/coveragepy/pull/1110
.. _issue 1123: https://github.com/nedbat/coveragepy/issues/1123
diff --git a/coverage/sqldata.py b/coverage/sqldata.py
index b28b83b4..a150fdfd 100644
--- a/coverage/sqldata.py
+++ b/coverage/sqldata.py
@@ -486,9 +486,9 @@ class CoverageData(SimpleReprMixin):
assert lines or arcs
assert not (lines and arcs)
if lines and self._has_arcs:
- raise CoverageException("Can't add lines to existing arc data")
+ raise CoverageException("Can't add line measurements to existing branch data")
if arcs and self._has_lines:
- raise CoverageException("Can't add arcs to existing line data")
+ raise CoverageException("Can't add branch measurements to existing line data")
if not self._has_arcs and not self._has_lines:
self._has_lines = lines
self._has_arcs = arcs
diff --git a/tests/test_data.py b/tests/test_data.py
index fe37bd9e..eac9c36f 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -159,13 +159,15 @@ class CoverageDataTest(DataTestHelpers, CoverageTest):
def test_cant_add_arcs_with_lines(self):
covdata = CoverageData()
covdata.add_lines(LINES_1)
- with pytest.raises(CoverageException, match="Can't add arcs to existing line data"):
+ msg = "Can't add branch measurements to existing line data"
+ with pytest.raises(CoverageException, match=msg):
covdata.add_arcs(ARCS_3)
def test_cant_add_lines_with_arcs(self):
covdata = CoverageData()
covdata.add_arcs(ARCS_3)
- with pytest.raises(CoverageException, match="Can't add lines to existing arc data"):
+ msg = "Can't add line measurements to existing branch data"
+ with pytest.raises(CoverageException, match=msg):
covdata.add_lines(LINES_1)
def test_touch_file_with_lines(self):