Skip to content

Commit 2ecaf72

Browse files
committed
refactor: we don't need a check for v4 data files anymore
1 parent 5407340 commit 2ecaf72

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

coverage/sqlitedb.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,6 @@ def _execute(self, sql: str, parameters: Iterable[Any]) -> sqlite3.Cursor:
127127
return self.con.execute(sql, parameters) # type: ignore[arg-type]
128128
except sqlite3.Error as exc:
129129
msg = str(exc)
130-
if not self.no_disk:
131-
try:
132-
# `execute` is the first thing we do with the database, so try
133-
# hard to provide useful hints if something goes wrong now.
134-
with open(self.filename, "rb") as bad_file:
135-
cov4_sig = b"!coverage.py: This is a private format"
136-
if bad_file.read(len(cov4_sig)) == cov4_sig:
137-
msg = (
138-
"Looks like a coverage 4.x data file. "
139-
+ "Are you mixing versions of coverage?"
140-
)
141-
except Exception:
142-
pass
143130
if self.debug.should("sql"):
144131
self.debug.write(f"EXCEPTION from execute: {exc_one_line(exc)}")
145132
raise DataError(f"Couldn't use data file {self.filename!r}: {msg}") from exc

tests/test_api.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import coverage
2424
from coverage import Coverage, env
2525
from coverage.data import line_counts, sorted_lines
26-
from coverage.exceptions import ConfigError, CoverageException, DataError, NoDataError, NoSource
26+
from coverage.exceptions import ConfigError, CoverageException, NoDataError, NoSource
2727
from coverage.files import abs_file, relative_filename
2828
from coverage.misc import import_local_file
2929
from coverage.types import FilePathClasses, FilePathType, TCovKwargs
@@ -355,17 +355,6 @@ def test_completely_zero_reporting(self) -> None:
355355
last = self.last_line_squeezed(self.stdout())
356356
assert "TOTAL 1 1 0%" == last
357357

358-
def test_cov4_data_file(self) -> None:
359-
cov4_data = (
360-
"!coverage.py: This is a private format, don't read it directly!"
361-
+ '{"lines":{"/somewhere/not/really.py":[1,5,2,3]}}'
362-
)
363-
self.make_file(".coverage", cov4_data)
364-
cov = coverage.Coverage()
365-
with pytest.raises(DataError, match="Looks like a coverage 4.x data file"):
366-
cov.load()
367-
cov.erase()
368-
369358
def make_code1_code2(self) -> None:
370359
"""Create the code1.py and code2.py files."""
371360
self.make_file(

0 commit comments

Comments
 (0)