summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-13 19:23:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-14 08:12:49 -0500
commitb82e9fd8766a77c2a275bde7b574f3e8cb529f8f (patch)
treef310ea38a19f2b4e8c93ee3e3a5b8a99aa43351a /tests/test_api.py
parent342e7da2941ae5291f1a94b6ad66ce489f6985fe (diff)
downloadpython-coveragepy-git-nedbat/exceptions.tar.gz
refactor: specialize exceptionsnedbat/exceptions
CoverageException is fine as a base class, but not good to use for raising (and catching sometimes). Introduce specialized exceptions that allow third-party tools to integrate better.
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 9d56b23e..6b065709 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -18,7 +18,7 @@ import pytest
import coverage
from coverage import env
from coverage.data import line_counts
-from coverage.exceptions import CoverageException
+from coverage.exceptions import CoverageException, DataError, NoDataError, NoSource
from coverage.files import abs_file, relative_filename
from coverage.misc import import_local_file
@@ -293,7 +293,7 @@ class ApiTest(CoverageTest):
# empty summary reports raise exception, just like the xml report
cov = coverage.Coverage()
cov.erase()
- with pytest.raises(CoverageException, match="No data to report."):
+ with pytest.raises(NoDataError, match="No data to report."):
cov.report()
def test_completely_zero_reporting(self):
@@ -322,7 +322,7 @@ class ApiTest(CoverageTest):
)
self.make_file(".coverage", cov4_data)
cov = coverage.Coverage()
- with pytest.raises(CoverageException, match="Looks like a coverage 4.x data file"):
+ with pytest.raises(DataError, match="Looks like a coverage 4.x data file"):
cov.load()
cov.erase()
@@ -445,7 +445,7 @@ class ApiTest(CoverageTest):
self.assert_exists(".coverage")
cov2 = coverage.Coverage()
- with pytest.raises(CoverageException, match=r"No data to combine"):
+ with pytest.raises(NoDataError, match=r"No data to combine"):
cov2.combine(strict=True, keep=False)
cov3 = coverage.Coverage()
@@ -1126,7 +1126,7 @@ class RelativePathTest(CoverageTest):
with change_dir("new"):
cov = coverage.Coverage()
cov.load()
- with pytest.raises(CoverageException, match=expected):
+ with pytest.raises(NoSource, match=expected):
cov.report()
def test_moving_stuff_with_relative(self):