@@ -49,6 +49,7 @@ def test_datatypes(tg, datatype):
4949 data = db .read ()['data' ]
5050 assert data [0 ]['v1' ] == v
5151 assert data [0 ]['v2' ] is None
52+ db ._connection .close ()
5253
5354
5455def test_list_valued (tg , translate ):
@@ -62,6 +63,7 @@ def test_list_valued(tg, translate):
6263 assert data [0 ]['vv' ] == ['a' , 'b' , ' c' ]
6364 assert data [1 ]['vv' ] == []
6465 db .write (data = [{'v' : ['a' , 'b' , None ]}])
66+ db ._connection .close ()
6567
6668
6769def test_list_valued_non_text (tg , translate ):
@@ -72,13 +74,15 @@ def test_list_valued_non_text(tg, translate):
7274 data = db .read ()['data' ]
7375 assert data [0 ]['vv' ] == [1 , 2 , 3 ]
7476 assert data [1 ]['vv' ] is None
77+ db ._connection .close ()
7578
7679
7780def test_required (tg ):
7881 tg .tables [0 ].tableSchema .columns .append (Column .fromvalue ({'required' : 'True' , 'name' : 'v' }))
7982 db = Database (tg )
8083 with pytest .raises (sqlite3 .IntegrityError ):
8184 db .write (data = [{'v' : None }])
85+ db ._connection .close ()
8286
8387
8488@pytest .mark .parametrize (
@@ -106,6 +110,7 @@ def test_constraints(tg, datatype, value, error):
106110 db .write (data = [{'v' : value }])
107111 else :
108112 db .write (data = [{'v' : value }])
113+ db ._connection .close ()
109114
110115
111116def test_file (tmp_path , tg ):
@@ -163,6 +168,7 @@ def test_foreign_keys(tg, translate):
163168 db .write (ref = [{'ref' : 'x' }], data = [{'v' : 'x' }])
164169 # 'vv' is used as column name as specified by the translate fixture:
165170 assert 'vv' in db .read ()['data' ][0 ]
171+ db ._connection .close ()
166172
167173
168174def test_self_referential_foreign_keys (tg ):
@@ -177,13 +183,16 @@ def test_self_referential_foreign_keys(tg):
177183 db = Database (tg )
178184 db .write (data = [{'id' : '1' , 'ref' : '2' }, {'id' : '2' , 'ref' : None }])
179185 assert len (db .read ()['data' ]) == 2
186+ db ._connection .close ()
180187
181188 db = Database (tg , drop_self_referential_fks = False )
182189 with pytest .raises (sqlite3 .IntegrityError ):
183190 db .write (data = [{'id' : '1' , 'ref' : '2' }, {'id' : '2' , 'ref' : None }])
191+ db ._connection .close ()
184192
185193 db = Database (tg , drop_self_referential_fks = False )
186194 db .write (data = [{'id' : '2' , 'ref' : None }, {'id' : '1' , 'ref' : '2' }])
195+ db ._connection .close ()
187196
188197
189198@pytest .fixture
@@ -232,6 +241,7 @@ def test_many_to_many(tg_with_foreign_keys):
232241 # Associations between the same pair of tables are grouped by foreign key column:
233242 assert res ['ref1' ] == ['y' , 'x' ]
234243 assert res ['ref2' ] == []
244+ db ._connection .close ()
235245
236246
237247def test_many_to_many_no_context (tg_with_foreign_keys ):
@@ -249,6 +259,7 @@ def select_many_to_many(self, db, table, context):
249259 res = db .read ()['ref' ][0 ]
250260 # The context will then be returned for **each** foreign key column!
251261 assert res ['ref2' ] == [('y' , '1234' ), ('x' , '1234' )]
262+ db ._connection .close ()
252263
253264
254265def test_many_to_many_self_referential (tg ):
@@ -267,6 +278,7 @@ def test_many_to_many_self_referential(tg):
267278 db .write (data = [{'v' : 'x' , 'ref' : ['y' ]}])
268279 db .write (data = [{'v' : 'x' , 'ref' : []}, {'v' : 'y' , 'ref' : ['x' , 'y' ]}])
269280 assert db .read ()['data' ][1 ]['ref' ] == ['x' , 'y' ]
281+ db ._connection .close ()
270282
271283
272284def test_integration ():
@@ -278,6 +290,7 @@ def test_integration():
278290 db .write_from_tg ()
279291 for table , items in db .read ().items ():
280292 assert items == orig [table ]
293+ db ._connection .close ()
281294
282295
283296def test_write_file_exists (tmp_path ):
0 commit comments