summaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-12-22 09:48:17 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-12-22 11:09:01 -0500
commit0d6a8784cdafd46409fe187ad87b7c38772d6d1b (patch)
tree72d83360eb575ad10d8ec0213a242bd9e0bf156c /tests/test_api.py
parentd66d496b53e3fd8ba891a2704d82e0b6a0be1502 (diff)
downloadpython-coveragepy-git-0d6a8784cdafd46409fe187ad87b7c38772d6d1b.tar.gz
Detect when a 4.x data file is being read. #886
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 8fa81d07..30a90c3c 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -295,6 +295,17 @@ class ApiTest(CoverageTest):
with self.assertRaisesRegex(CoverageException, "No data to report."):
cov.report()
+ def test_cov4_data_file(self):
+ cov4_data = (
+ "!coverage.py: This is a private format, don't read it directly!"
+ '{"lines":{"/private/tmp/foo.py":[1,5,2,3]}}'
+ )
+ self.make_file(".coverage", cov4_data)
+ cov = coverage.Coverage()
+ with self.assertRaisesRegex(CoverageException, "Looks like a coverage 4.x data file"):
+ cov.load()
+ cov.erase()
+
def make_code1_code2(self):
"""Create the code1.py and code2.py files."""
self.make_file("code1.py", """\
@@ -384,15 +395,11 @@ class ApiTest(CoverageTest):
cov.save()
self.assert_file_count(".coverage.*", 2)
- def make_bad_data_file(self):
- """Make one bad data file."""
- self.make_file(".coverage.foo", """La la la, this isn't coverage data!""")
-
def test_combining_corrupt_data(self):
# If you combine a corrupt data file, then you will get a warning,
# and the file will remain.
self.make_good_data_files()
- self.make_bad_data_file()
+ self.make_file(".coverage.foo", """La la la, this isn't coverage data!""")
cov = coverage.Coverage()
warning_regex = (
r"Couldn't use data file '.*\.coverage\.foo': file (is encrypted or )?is not a database"