mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 11:34:09 +02:00
Claude Code helped fix a ton of .close() warnings, refs #692
https://gistpreview.github.io/?730f0c5dc38528a1dd0615f330bd5481
This commit is contained in:
parent
f77ca0ec0d
commit
81b0599078
6 changed files with 119 additions and 30 deletions
|
|
@ -82,6 +82,7 @@ def test_tables_counts_and_columns(db_path):
|
|||
db = Database(db_path)
|
||||
with db.conn:
|
||||
db["lots"].insert_all([{"id": i, "age": i + 1} for i in range(30)])
|
||||
db.close()
|
||||
result = CliRunner().invoke(cli.cli, ["tables", "--counts", "--columns", db_path])
|
||||
assert (
|
||||
'[{"table": "Gosh", "count": 0, "columns": ["c1", "c2", "c3"]},\n'
|
||||
|
|
@ -117,6 +118,7 @@ def test_tables_counts_and_columns_csv(db_path, format, expected):
|
|||
db = Database(db_path)
|
||||
with db.conn:
|
||||
db["lots"].insert_all([{"id": i, "age": i + 1} for i in range(30)])
|
||||
db.close()
|
||||
result = CliRunner().invoke(
|
||||
cli.cli, ["tables", "--counts", "--columns", format, db_path]
|
||||
)
|
||||
|
|
@ -127,6 +129,7 @@ def test_tables_schema(db_path):
|
|||
db = Database(db_path)
|
||||
with db.conn:
|
||||
db["lots"].insert_all([{"id": i, "age": i + 1} for i in range(30)])
|
||||
db.close()
|
||||
result = CliRunner().invoke(cli.cli, ["tables", "--schema", db_path])
|
||||
assert (
|
||||
'[{"table": "Gosh", "schema": "CREATE TABLE Gosh (c1 text, c2 text, c3 text)"},\n'
|
||||
|
|
@ -188,6 +191,7 @@ def test_output_table(db_path, options, expected):
|
|||
for i in range(4)
|
||||
]
|
||||
)
|
||||
db.close()
|
||||
result = CliRunner().invoke(cli.cli, ["rows", db_path, "rows"] + options)
|
||||
assert result.exit_code == 0
|
||||
assert expected == result.output.strip()
|
||||
|
|
@ -243,6 +247,7 @@ def test_create_index(db_path):
|
|||
CliRunner().invoke(cli.cli, create_index_unique_args + [option]).exit_code
|
||||
== 0
|
||||
)
|
||||
db.close()
|
||||
|
||||
|
||||
def test_create_index_analyze(db_path):
|
||||
|
|
@ -622,6 +627,7 @@ def test_optimize(db_path, tables):
|
|||
)
|
||||
db["Gosh"].enable_fts(["c1", "c2", "c3"], fts_version="FTS4")
|
||||
db["Gosh2"].enable_fts(["c1", "c2", "c3"], fts_version="FTS5")
|
||||
db.close()
|
||||
size_before_optimize = os.stat(db_path).st_size
|
||||
result = CliRunner().invoke(cli.cli, ["optimize", db_path] + tables)
|
||||
assert result.exit_code == 0
|
||||
|
|
@ -1450,6 +1456,7 @@ def test_drop_table_error():
|
|||
with runner.isolated_filesystem():
|
||||
db = Database("test.db")
|
||||
db["t"].create({"pk": int}, pk="pk")
|
||||
db.close()
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
|
|
@ -1474,6 +1481,7 @@ def test_drop_view():
|
|||
db = Database("test.db")
|
||||
db.create_view("hello", "select 1")
|
||||
assert "hello" in db.view_names()
|
||||
db.close()
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
|
|
@ -1483,7 +1491,9 @@ def test_drop_view():
|
|||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
db = Database("test.db")
|
||||
assert "hello" not in db.view_names()
|
||||
db.close()
|
||||
|
||||
|
||||
def test_drop_view_error():
|
||||
|
|
@ -1491,6 +1501,7 @@ def test_drop_view_error():
|
|||
with runner.isolated_filesystem():
|
||||
db = Database("test.db")
|
||||
db["t"].create({"pk": int}, pk="pk")
|
||||
db.close()
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
|
|
@ -1728,10 +1739,13 @@ def test_transform(db_path, args, expected_schema):
|
|||
defaults={"age": 1},
|
||||
pk="id",
|
||||
)
|
||||
db.close()
|
||||
result = CliRunner().invoke(cli.cli, ["transform", db_path, "dogs"] + args)
|
||||
print(result.output)
|
||||
assert result.exit_code == 0
|
||||
db = Database(db_path)
|
||||
schema = db["dogs"].schema
|
||||
db.close()
|
||||
assert schema == expected_schema
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue