mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Don't use pytest_asyncio.fixture(scope="session") any more, refs #1959
Also got rid of the weird memory=False hack: https://github.com/simonw/datasette/pull/1960#issuecomment-1354053151
This commit is contained in:
parent
95900b9d02
commit
d94d363ec0
3 changed files with 14 additions and 13 deletions
|
|
@ -25,18 +25,12 @@ UNDOCUMENTED_PERMISSIONS = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop():
|
||||
return asyncio.get_event_loop()
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="session")
|
||||
@pytest_asyncio.fixture
|
||||
async def ds_client():
|
||||
from datasette.app import Datasette
|
||||
from .fixtures import METADATA, PLUGINS_DIR
|
||||
|
||||
ds = Datasette(
|
||||
memory=False,
|
||||
metadata=METADATA,
|
||||
plugins_dir=PLUGINS_DIR,
|
||||
settings={
|
||||
|
|
@ -51,12 +45,14 @@ async def ds_client():
|
|||
from .fixtures import TABLES, TABLE_PARAMETERIZED_SQL
|
||||
|
||||
db = ds.add_memory_database("fixtures")
|
||||
ds.remove_database("_memory")
|
||||
|
||||
def prepare(conn):
|
||||
conn.executescript(TABLES)
|
||||
for sql, params in TABLE_PARAMETERIZED_SQL:
|
||||
with conn:
|
||||
conn.execute(sql, params)
|
||||
if not conn.execute("select count(*) from sqlite_master").fetchone()[0]:
|
||||
conn.executescript(TABLES)
|
||||
for sql, params in TABLE_PARAMETERIZED_SQL:
|
||||
with conn:
|
||||
conn.execute(sql, params)
|
||||
|
||||
await db.execute_write_fn(prepare)
|
||||
return ds.client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue