Declare ds_client as session-scoped so auto-close plugin spares it

ds_client already caches a single Datasette for the whole session via a
module-level _ds_client global, so the declared fixture scope should
match. With function scope the auto-close plugin correctly closes it
after the first test that uses it, which then breaks every subsequent
test that reuses the cached (now-closed) instance — as seen in the CI
coverage job, which runs serially rather than under pytest-xdist.

Refs #2692

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Simon Willison 2026-04-16 20:40:51 -07:00
commit c9a7dc9be2

View file

@ -53,7 +53,7 @@ def bare_ds():
return Datasette(memory=True)
@pytest_asyncio.fixture
@pytest_asyncio.fixture(scope="session")
async def ds_client():
from datasette.app import Datasette
from datasette.database import Database