Skip to content

Commit 9703cf7

Browse files
committed
test_wal_preservation: add debugging for macOS and iOS failures
1 parent b47206a commit 9703cf7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/test_sqlite3/test_dbapi.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,26 +728,34 @@ def test_database_keyword(self):
728728
with contextlib.closing(sqlite.connect(database=":memory:")) as cx:
729729
self.assertEqual(type(cx), sqlite.Connection)
730730

731-
@unittest.skipIf(sys.platform == "darwin", "skipped on macOS")
731+
# @hashbrowncipher skipped this test on mac, don't know why, rerunning to test it
732732
def test_wal_preservation(self):
733733
with tempfile.TemporaryDirectory() as dirname:
734734
path = os.path.join(dirname, "db.sqlite")
735735
with contextlib.closing(sqlite.connect(path)) as cx:
736736
cx.file_control(sqlite.SQLITE_FCNTL_PERSIST_WAL, 1)
737+
# Check that it was set successfully:
738+
rc = cx.file_control(sqlite.SQLITE_FCNTL_PERSIST_WAL, -1)
739+
assert rc == 1, f"cx.file_control(SQLITE_FCNTL_PERSIST_WAL) failed to set flag"
740+
737741
cu = cx.cursor()
738-
cu.execute("PRAGMA journal_mode = WAL")
742+
result = cu.execute("PRAGMA journal_mode = WAL").fetchall()
743+
assert result == [('wal',)], f"journal_mode could not be set to WAL, is {result}"
739744
cu.execute("CREATE TABLE foo (id int)")
740745
cu.execute("INSERT INTO foo (id) VALUES (1)")
741746
self.assertTrue(os.path.exists(path + "-wal"))
742747
self.assertTrue(os.path.exists(path + "-wal"))
743748

744749
with contextlib.closing(sqlite.connect(path)) as cx:
750+
# Check that we can read the default value when we didn't set it explicitly:
751+
rc = cx.file_control(sqlite.SQLITE_FCNTL_PERSIST_WAL, -1)
752+
assert rc == 0, f"SQLITE_FCNTL_PERSIST_WAL should be off by default"
753+
745754
cu = cx.cursor()
746755
self.assertTrue(os.path.exists(path + "-wal"))
747756
cu.execute("INSERT INTO foo (id) VALUES (2)")
748757
self.assertFalse(os.path.exists(path + "-wal"))
749758

750-
751759
def test_file_control_raises(self):
752760
with memory_database() as cx:
753761
with self.assertRaises(sqlite.InternalError):

0 commit comments

Comments
 (0)