File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -170,26 +170,35 @@ def test_in_transaction_ro(self):
170
170
with self .assertRaises (AttributeError ):
171
171
self .cx .in_transaction = True
172
172
173
+
174
+ class OpenTests (unittest .TestCase ):
175
+ def tearDown (self ):
176
+ unlink (TESTFN )
177
+
173
178
def test_open_with_path_like_object (self ):
174
179
""" Checks that we can successfully connect to a database using an object that
175
180
is PathLike, i.e. has __fspath__(). """
176
- self .addCleanup (unlink , TESTFN )
177
181
class Path :
178
182
def __fspath__ (self ):
179
183
return TESTFN
180
184
path = Path ()
181
185
with sqlite .connect (path ) as cx :
182
186
cx .execute ('create table test(id integer)' )
187
+ cx .close ()
183
188
184
189
def test_open_uri (self ):
185
- self .addCleanup (unlink , TESTFN )
186
190
with sqlite .connect (TESTFN ) as cx :
187
191
cx .execute ('create table test(id integer)' )
192
+ cx .close ()
193
+
188
194
with sqlite .connect ('file:' + TESTFN , uri = True ) as cx :
189
195
cx .execute ('insert into test(id) values(0)' )
196
+ cx .close ()
197
+
190
198
with sqlite .connect ('file:' + TESTFN + '?mode=ro' , uri = True ) as cx :
191
199
with self .assertRaises (sqlite .OperationalError ):
192
200
cx .execute ('insert into test(id) values(1)' )
201
+ cx .close ()
193
202
194
203
195
204
class CursorTests (unittest .TestCase ):
@@ -942,6 +951,7 @@ def suite():
942
951
CursorTests ,
943
952
ExtensionTests ,
944
953
ModuleTests ,
954
+ OpenTests ,
945
955
SqliteOnConflictTests ,
946
956
ThreadTests ,
947
957
]
Original file line number Diff line number Diff line change @@ -259,6 +259,8 @@ def trace(statement):
259
259
cur .execute (queries [0 ])
260
260
con2 .execute ("create table bar(x)" )
261
261
cur .execute (queries [1 ])
262
+ con1 .close ()
263
+ con2 .close ()
262
264
self .assertEqual (traced_statements , queries )
263
265
264
266
You can’t perform that action at this time.
0 commit comments