mirror of
https://github.com/simonw/datasette.git
synced 2026-06-06 09:07:00 +02:00
From 409 warnings down to 52 warnings.
By closing unclosed database connections. Refs #2614
This commit is contained in:
parent
9c164572d3
commit
f02484c3de
14 changed files with 75 additions and 27 deletions
|
|
@ -472,7 +472,9 @@ def test_serve_duplicate_database_names(tmpdir):
|
|||
nested.mkdir()
|
||||
db_2_path = str(tmpdir / "nested" / "db.db")
|
||||
for path in (db_1_path, db_2_path):
|
||||
sqlite3.connect(path).execute("vacuum")
|
||||
conn = sqlite3.connect(path)
|
||||
conn.execute("vacuum")
|
||||
conn.close()
|
||||
result = runner.invoke(cli, [db_1_path, db_2_path, "--get", "/-/databases.json"])
|
||||
assert result.exit_code == 0, result.output
|
||||
databases = json.loads(result.output)
|
||||
|
|
@ -486,7 +488,9 @@ def test_weird_database_names(tmpdir, filename):
|
|||
# https://github.com/simonw/datasette/issues/1181
|
||||
runner = CliRunner()
|
||||
db_path = str(tmpdir / filename)
|
||||
sqlite3.connect(db_path).execute("vacuum")
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.execute("vacuum")
|
||||
conn.close()
|
||||
result1 = runner.invoke(cli, [db_path, "--get", "/"])
|
||||
assert result1.exit_code == 0, result1.output
|
||||
filename_no_stem = filename.rsplit(".", 1)[0]
|
||||
|
|
@ -523,7 +527,9 @@ def test_duplicate_database_files_error(tmpdir):
|
|||
"""Test that passing the same database file multiple times raises an error"""
|
||||
runner = CliRunner()
|
||||
db_path = str(tmpdir / "test.db")
|
||||
sqlite3.connect(db_path).execute("vacuum")
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.execute("vacuum")
|
||||
conn.close()
|
||||
|
||||
# Test with exact duplicate
|
||||
result = runner.invoke(cli, ["serve", db_path, db_path, "--get", "/"])
|
||||
|
|
@ -542,7 +548,9 @@ def test_duplicate_database_files_error(tmpdir):
|
|||
config_dir = tmpdir / "config"
|
||||
config_dir.mkdir()
|
||||
config_db_path = str(config_dir / "data.db")
|
||||
sqlite3.connect(config_db_path).execute("vacuum")
|
||||
conn = sqlite3.connect(config_db_path)
|
||||
conn.execute("vacuum")
|
||||
conn.close()
|
||||
|
||||
result3 = runner.invoke(
|
||||
cli, ["serve", config_db_path, str(config_dir), "--get", "/"]
|
||||
|
|
@ -553,7 +561,9 @@ def test_duplicate_database_files_error(tmpdir):
|
|||
|
||||
# Test that mixing a file NOT in the directory with a directory works fine
|
||||
other_db_path = str(tmpdir / "other.db")
|
||||
sqlite3.connect(other_db_path).execute("vacuum")
|
||||
conn = sqlite3.connect(other_db_path)
|
||||
conn.execute("vacuum")
|
||||
conn.close()
|
||||
|
||||
result4 = runner.invoke(
|
||||
cli, ["serve", other_db_path, str(config_dir), "--get", "/-/databases.json"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue