From d23b32c3e57469f0c0de149aee8594205dfdb319 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 16 Apr 2026 20:25:58 -0700 Subject: [PATCH] Call ds.close() in more places in tests Refs #2692 --- tests/test_api_write.py | 7 +------ tests/test_column_types.py | 10 ++-------- tests/test_docs_plugins.py | 1 + tests/test_write_wrapper.py | 1 + 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/test_api_write.py b/tests/test_api_write.py index 9ba08848..64f91701 100644 --- a/tests/test_api_write.py +++ b/tests/test_api_write.py @@ -22,12 +22,7 @@ def ds_write(tmp_path_factory): ds = Datasette([db_path], immutables=[db_path_immutable]) ds.root_enabled = True yield ds - # Close both setup connections plus any Datasette-managed connections. - db1.close() - db2.close() - for database in ds.databases.values(): - if not database.is_memory: - database.close() + ds.close() def write_token(ds, actor_id="root", permissions=None): diff --git a/tests/test_column_types.py b/tests/test_column_types.py index 6e89acb9..d77f2cf5 100644 --- a/tests/test_column_types.py +++ b/tests/test_column_types.py @@ -52,10 +52,7 @@ def ds_ct(tmp_path_factory): ) ds.root_enabled = True yield ds - db.close() - for database in ds.databases.values(): - if not database.is_memory: - database.close() + ds.close() @pytest.fixture @@ -95,10 +92,7 @@ def ds_ct_editor_permission(tmp_path_factory): ) ds.root_enabled = True yield ds - db.close() - for database in ds.databases.values(): - if not database.is_memory: - database.close() + ds.close() def write_token(ds, actor_id="root", permissions=None): diff --git a/tests/test_docs_plugins.py b/tests/test_docs_plugins.py index c51858d3..613160ac 100644 --- a/tests/test_docs_plugins.py +++ b/tests/test_docs_plugins.py @@ -23,6 +23,7 @@ async def datasette_with_plugin(): yield datasette finally: datasette.pm.unregister(name="undo") + datasette.close() # -- end datasette_with_plugin_fixture -- diff --git a/tests/test_write_wrapper.py b/tests/test_write_wrapper.py index c2ceb344..48c964b4 100644 --- a/tests/test_write_wrapper.py +++ b/tests/test_write_wrapper.py @@ -505,6 +505,7 @@ def ds_with_event_tracking(tmp_path): ds.track_event = recording_track_event yield ds + ds.close() @pytest.mark.asyncio