mirror of
https://github.com/simonw/datasette.git
synced 2026-10-07 18:06:59 +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
|
|
@ -208,6 +208,7 @@ def test_detect_fts(open_quote, close_quote):
|
|||
assert None is utils.detect_fts(conn, "Test_View")
|
||||
assert None is utils.detect_fts(conn, "r")
|
||||
assert "Street_Tree_List_fts" == utils.detect_fts(conn, "Street_Tree_List")
|
||||
conn.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("table", ("regular", "has'single quote"))
|
||||
|
|
@ -222,6 +223,7 @@ def test_detect_fts_different_table_names(table):
|
|||
conn = utils.sqlite3.connect(":memory:")
|
||||
conn.executescript(sql)
|
||||
assert "{table}_fts".format(table=table) == utils.detect_fts(conn, table)
|
||||
conn.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -359,6 +361,7 @@ def test_table_columns():
|
|||
create table places (id integer primary key, name text, bob integer)
|
||||
""")
|
||||
assert ["id", "name", "bob"] == utils.table_columns(conn, "places")
|
||||
conn.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -433,11 +436,13 @@ def test_check_connection_spatialite_raises():
|
|||
conn = sqlite3.connect(path)
|
||||
with pytest.raises(utils.SpatialiteConnectionProblem):
|
||||
utils.check_connection(conn)
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_check_connection_passes():
|
||||
conn = sqlite3.connect(":memory:")
|
||||
utils.check_connection(conn)
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_call_with_supported_arguments():
|
||||
|
|
@ -564,10 +569,14 @@ def test_display_actor(actor, expected):
|
|||
async def test_initial_path_for_datasette(tmp_path_factory, dbs, expected_path):
|
||||
db_dir = tmp_path_factory.mktemp("dbs")
|
||||
one_table = str(db_dir / "one.db")
|
||||
sqlite3.connect(one_table).execute("create table one (id integer primary key)")
|
||||
conn1 = sqlite3.connect(one_table)
|
||||
conn1.execute("create table one (id integer primary key)")
|
||||
conn1.close()
|
||||
two_tables = str(db_dir / "two.db")
|
||||
sqlite3.connect(two_tables).execute("create table two (id integer primary key)")
|
||||
sqlite3.connect(two_tables).execute("create table three (id integer primary key)")
|
||||
conn2 = sqlite3.connect(two_tables)
|
||||
conn2.execute("create table two (id integer primary key)")
|
||||
conn2.execute("create table three (id integer primary key)")
|
||||
conn2.close()
|
||||
datasette = Datasette(
|
||||
[{"one_table": one_table, "two_tables": two_tables}[db] for db in dbs]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue