Ported setup.py to pyproject.toml (#2555)

* Ported setup.py to pyproject.toml, refs #2553

* Make fixtures tests less flaky

The in-memory fixtures table was being shared between different
instances of the test client, leading to occasional errors when
running the full test suite.
This commit is contained in:
Simon Willison 2025-10-30 10:41:41 -07:00 committed by GitHub
commit ce4b0794b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 141 additions and 147 deletions

View file

@ -42,7 +42,9 @@ def wait_until_responds(url, timeout=5.0, client=httpx, **kwargs):
@pytest_asyncio.fixture
async def ds_client():
from datasette.app import Datasette
from datasette.database import Database
from .fixtures import CONFIG, METADATA, PLUGINS_DIR
import secrets
global _ds_client
if _ds_client is not None:
@ -63,7 +65,10 @@ async def ds_client():
)
from .fixtures import TABLES, TABLE_PARAMETERIZED_SQL
db = ds.add_memory_database("fixtures")
# Use a unique memory_name to avoid collisions between different
# Datasette instances in the same process, but use "fixtures" for routing
unique_memory_name = f"fixtures_{secrets.token_hex(8)}"
db = ds.add_database(Database(ds, memory_name=unique_memory_name), name="fixtures")
ds.remove_database("_memory")
def prepare(conn):