Skip to content

Commit 32606c2

Browse files
committed
close sqlite connection
1 parent fd24e7b commit 32606c2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/unit/synapseclient/services/unit_test_migration_and_types_async.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ def _populate_db(db_path: str) -> None:
224224
128,
225225
),
226226
]
227-
with sqlite3.connect(db_path) as conn:
227+
conn = sqlite3.connect(db_path)
228+
try:
228229
cursor = conn.cursor()
229230
_ensure_schema(cursor)
230231
cursor.executemany(
@@ -236,12 +237,14 @@ def _populate_db(db_path: str) -> None:
236237
rows,
237238
)
238239
conn.commit()
240+
finally:
241+
conn.close()
239242

240243

241244
@pytest.fixture
242245
def result_db():
243-
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
244-
path = f.name
246+
fd, path = tempfile.mkstemp(suffix=".db")
247+
os.close(fd)
245248
_populate_db(path)
246249
yield path
247250
os.unlink(path)

0 commit comments

Comments
 (0)