This should make it easier to refactor the code for removing the databases package.
32 lines
649 B
Python
32 lines
649 B
Python
import asyncio
|
|
|
|
import pytest
|
|
import pytest_asyncio
|
|
|
|
from unwind import db
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def event_loop():
|
|
loop = asyncio.new_event_loop()
|
|
yield loop
|
|
loop.run_until_complete(loop.shutdown_asyncgens())
|
|
loop.run_until_complete(loop.shutdown_default_executor())
|
|
loop.close()
|
|
|
|
|
|
@pytest_asyncio.fixture(scope="session")
|
|
async def shared_conn():
|
|
c = db._shared_connection()
|
|
await c.connect()
|
|
|
|
await db.apply_db_patches(c)
|
|
yield c
|
|
|
|
await c.disconnect()
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def conn(shared_conn):
|
|
async with shared_conn.transaction(force_rollback=True):
|
|
yield shared_conn
|