summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-01-21 06:40:54 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-01-21 06:40:54 -0500
commit5fc8f8404bbb879e1c6669e697793259622ebf4a (patch)
treefa48509e3fd143c67a351bf617c07b852e3f88b2
parenta533780834c2223edb1e5db51457f53f677c1ac8 (diff)
downloadpython-coveragepy-git-5fc8f8404bbb879e1c6669e697793259622ebf4a.tar.gz
test: add one sql test to cover an unlikely case in the code
-rw-r--r--tests/test_data.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index acdca7d8..f9928467 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -584,10 +584,8 @@ class CoverageDataInTempDirTest(CoverageTest):
assert_arcs3_data(covdata2)
def test_read_errors(self):
- msg = r"Couldn't .* '.*[/\\]{}': \S+"
-
self.make_file("xyzzy.dat", "xyzzy")
- with pytest.raises(DataError, match=msg.format("xyzzy.dat")):
+ with pytest.raises(DataError, match=r"Couldn't .* '.*[/\\]xyzzy.dat': \S+"):
covdata = DebugCoverageData("xyzzy.dat")
covdata.read()
assert not covdata
@@ -595,7 +593,7 @@ class CoverageDataInTempDirTest(CoverageTest):
def test_hard_read_error(self):
self.make_file("noperms.dat", "go away")
os.chmod("noperms.dat", 0)
- with pytest.raises(DataError, match=r"Couldn't .* '.*[/\\]noperms.dat': "):
+ with pytest.raises(DataError, match=r"Couldn't .* '.*[/\\]noperms.dat': \S+"):
covdata = DebugCoverageData("noperms.dat")
covdata.read()
@@ -610,7 +608,7 @@ class CoverageDataInTempDirTest(CoverageTest):
sqldb.close = lambda: 1/0
covdata.add_lines(LINES_1)
- def test_read_sql_errors(self):
+ def test_wrong_schema_version(self):
with sqlite3.connect("wrong_schema.db") as con:
con.execute("create table coverage_schema (version integer)")
con.execute("insert into coverage_schema (version) values (99)")
@@ -620,6 +618,16 @@ class CoverageDataInTempDirTest(CoverageTest):
covdata.read()
assert not covdata
+ def test_wrong_schema_schema(self):
+ with sqlite3.connect("wrong_schema_schema.db") as con:
+ con.execute("create table coverage_schema (xyzzy integer)")
+ con.execute("insert into coverage_schema (xyzzy) values (99)")
+ msg = r"Data file .* doesn't seem to be a coverage data file: .* no such column"
+ with pytest.raises(DataError, match=msg):
+ covdata = DebugCoverageData("wrong_schema_schema.db")
+ covdata.read()
+ assert not covdata
+
class CoverageDataFilesTest(CoverageTest):
"""Tests of CoverageData file handling."""