From 948c307c89c9f61256bd96b770fa5b14ee4fe383 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 19 Aug 2018 07:47:54 -0400 Subject: PyPy needs to close cursors from pragmas --- coverage/sqldata.py | 7 +++++-- tests/coveragetest.py | 1 - tests/test_data.py | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/coverage/sqldata.py b/coverage/sqldata.py index f53561e7..f92e245b 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -3,6 +3,7 @@ """Sqlite coverage data.""" +# TODO: get sys_info for data class, so we can see sqlite version etc # TODO: get rid of skip_unless_data_storage_is_json # TODO: get rid of "JSON message" and "SQL message" in the tests # TODO: check the schema @@ -403,9 +404,11 @@ class Sqlite(SimpleRepr): self.con = sqlite3.connect(self.filename) # This pragma makes writing faster. It disables rollbacks, but we never need them. - self.execute("pragma journal_mode=off") + # PyPy needs the .close() calls here, or sqlite gets twisted up: + # https://bitbucket.org/pypy/pypy/issues/2872/default-isolation-mode-is-different-on + self.execute("pragma journal_mode=off").close() # This pragma makes writing faster. - self.execute("pragma synchronous=off") + self.execute("pragma synchronous=off").close() def close(self): self.con.close() diff --git a/tests/coveragetest.py b/tests/coveragetest.py index cd6bb9fc..b804a782 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -95,7 +95,6 @@ class CoverageTest( if STORAGE != "json": self.skipTest("Not using JSON for data storage") - def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. diff --git a/tests/test_data.py b/tests/test_data.py index 48df81fd..00d5d294 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -105,6 +105,8 @@ class DataTestHelpers(CoverageTest): class CoverageDataTest(DataTestHelpers, CoverageTest): """Test cases for CoverageData.""" + # SQL data storage always has files on disk, even without .write(). + # We need to separate the tests so they don't clobber each other. run_in_temp_dir = STORAGE == "sql" def test_empty_data_is_false(self): -- cgit v1.2.1