Skip to content

Commit b75d18d

Browse files
committed
Close the connections opened by the iterdump virtual-table test
1 parent 774d467 commit b75d18d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/test/test_sqlite3/test_dump.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sqlite3
44
import unittest
5+
from contextlib import closing
56

67
from test.support.os_helper import TESTFN, unlink
78

@@ -253,7 +254,7 @@ def test_dump_virtual_tables(self):
253254
def test_dump_virtual_table_data_roundtrip(self):
254255
# gh-153729: a populated virtual table must round-trip through iterdump().
255256
self.addCleanup(unlink, TESTFN)
256-
with sqlite3.connect(TESTFN) as src:
257+
with closing(sqlite3.connect(TESTFN)) as src:
257258
src.execute("CREATE VIRTUAL TABLE test USING fts4(example)")
258259
src.execute("INSERT INTO test(example) VALUES('hello world')")
259260
src.execute("INSERT INTO test(example) VALUES('second row')")
@@ -266,12 +267,12 @@ def test_dump_virtual_table_data_roundtrip(self):
266267

267268
restored_path = f"{TESTFN}.restored"
268269
self.addCleanup(unlink, restored_path)
269-
with sqlite3.connect(restored_path) as dst:
270+
with closing(sqlite3.connect(restored_path)) as dst:
270271
# Defensive mode blocks writable_schema writes to sqlite_master.
271272
dst.setconfig(sqlite3.SQLITE_DBCONFIG_DEFENSIVE, False)
272273
dst.setconfig(sqlite3.SQLITE_DBCONFIG_WRITABLE_SCHEMA, True)
273274
dst.executescript(script)
274-
with sqlite3.connect(restored_path) as restored:
275+
with closing(sqlite3.connect(restored_path)) as restored:
275276
rows = restored.execute(
276277
"SELECT example FROM test ORDER BY docid"
277278
).fetchall()

0 commit comments

Comments
 (0)