@@ -82,7 +82,6 @@ def test_tables_counts_and_columns(db_path):
8282 db = Database (db_path )
8383 with db .conn :
8484 db ["lots" ].insert_all ([{"id" : i , "age" : i + 1 } for i in range (30 )])
85- db .close ()
8685 result = CliRunner ().invoke (cli .cli , ["tables" , "--counts" , "--columns" , db_path ])
8786 assert (
8887 '[{"table": "Gosh", "count": 0, "columns": ["c1", "c2", "c3"]},\n '
@@ -118,7 +117,6 @@ def test_tables_counts_and_columns_csv(db_path, format, expected):
118117 db = Database (db_path )
119118 with db .conn :
120119 db ["lots" ].insert_all ([{"id" : i , "age" : i + 1 } for i in range (30 )])
121- db .close ()
122120 result = CliRunner ().invoke (
123121 cli .cli , ["tables" , "--counts" , "--columns" , format , db_path ]
124122 )
@@ -129,7 +127,6 @@ def test_tables_schema(db_path):
129127 db = Database (db_path )
130128 with db .conn :
131129 db ["lots" ].insert_all ([{"id" : i , "age" : i + 1 } for i in range (30 )])
132- db .close ()
133130 result = CliRunner ().invoke (cli .cli , ["tables" , "--schema" , db_path ])
134131 assert (
135132 '[{"table": "Gosh", "schema": "CREATE TABLE Gosh (c1 text, c2 text, c3 text)"},\n '
@@ -191,7 +188,6 @@ def test_output_table(db_path, options, expected):
191188 for i in range (4 )
192189 ]
193190 )
194- db .close ()
195191 result = CliRunner ().invoke (cli .cli , ["rows" , db_path , "rows" ] + options )
196192 assert result .exit_code == 0
197193 assert expected == result .output .strip ()
@@ -247,7 +243,6 @@ def test_create_index(db_path):
247243 CliRunner ().invoke (cli .cli , create_index_unique_args + [option ]).exit_code
248244 == 0
249245 )
250- db .close ()
251246
252247
253248def test_create_index_analyze (db_path ):
@@ -627,7 +622,6 @@ def test_optimize(db_path, tables):
627622 )
628623 db ["Gosh" ].enable_fts (["c1" , "c2" , "c3" ], fts_version = "FTS4" )
629624 db ["Gosh2" ].enable_fts (["c1" , "c2" , "c3" ], fts_version = "FTS5" )
630- db .close ()
631625 size_before_optimize = os .stat (db_path ).st_size
632626 result = CliRunner ().invoke (cli .cli , ["optimize" , db_path ] + tables )
633627 assert result .exit_code == 0
@@ -1456,7 +1450,6 @@ def test_drop_table_error():
14561450 with runner .isolated_filesystem ():
14571451 db = Database ("test.db" )
14581452 db ["t" ].create ({"pk" : int }, pk = "pk" )
1459- db .close ()
14601453 result = runner .invoke (
14611454 cli .cli ,
14621455 [
@@ -1481,7 +1474,6 @@ def test_drop_view():
14811474 db = Database ("test.db" )
14821475 db .create_view ("hello" , "select 1" )
14831476 assert "hello" in db .view_names ()
1484- db .close ()
14851477 result = runner .invoke (
14861478 cli .cli ,
14871479 [
@@ -1491,17 +1483,14 @@ def test_drop_view():
14911483 ],
14921484 )
14931485 assert result .exit_code == 0
1494- db = Database ("test.db" )
14951486 assert "hello" not in db .view_names ()
1496- db .close ()
14971487
14981488
14991489def test_drop_view_error ():
15001490 runner = CliRunner ()
15011491 with runner .isolated_filesystem ():
15021492 db = Database ("test.db" )
15031493 db ["t" ].create ({"pk" : int }, pk = "pk" )
1504- db .close ()
15051494 result = runner .invoke (
15061495 cli .cli ,
15071496 [
@@ -1739,13 +1728,10 @@ def test_transform(db_path, args, expected_schema):
17391728 defaults = {"age" : 1 },
17401729 pk = "id" ,
17411730 )
1742- db .close ()
17431731 result = CliRunner ().invoke (cli .cli , ["transform" , db_path , "dogs" ] + args )
17441732 print (result .output )
17451733 assert result .exit_code == 0
1746- db = Database (db_path )
17471734 schema = db ["dogs" ].schema
1748- db .close ()
17491735 assert schema == expected_schema
17501736
17511737
0 commit comments