Hello !
Just for reference it, I have make a .conftest file that generate db data from fixtures files (json) before all tests are runned (app writted async and tests writted sync)
import asyncio
from os import environ
from pathlib import Path
from advanced_alchemy.utils.fixtures import open_fixture_async
from dotenv import load_dotenv
from litestar.contrib.sqlalchemy.base import UUIDBase
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from modules.authentication.services import RoleService, UserService
def run_async(coro):
"""used because tests are sync and app/db async"""
return asyncio.run(coro)
def pytest_sessionstart(session):
"""pytest function who are runned before all tests on pytest call"""
run_async(fill_db_with_fixtures())