However with testing, a context is setup in a fixture and is not being propagated to the underlying test, resulting in the underlying function not finding the required context and failing.
LookupError: <ContextVar name='db_session_context' at 0x1120f29a0>
tests/test_services/test_part_service.py:23: in test_part_get
item: PartModel = await part_service.create_part(obj_in) # noqa:
app/services/part_service.py:103: in create_part
db_session: AsyncSession = db_session_context.get()
E LookupError: <ContextVar name='db_session_context' at 0x1120f29a0>
--------------------------------- Captured Log ---------------------------------
--------------------------------- Captured Out ---------------------------------
--------------------------------- Captured Err ---------------------------------
INFO [alembic.env] DETECTED aiosqlite driver, stripping from DATABASE_URL for migration
INFO [alembic.env] Database URL: sqlite:///./tests/files/test.db
INFO [alembic.env] Running migrations online
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 9905971ce75e, Adds Parts Table
INFO [alembic.env] DETECTED aiosqlite driver, stripping from DATABASE_URL for migration
INFO [alembic.env] Database URL: sqlite:///./tests/files/test.db
INFO [alembic.env] Running migrations online
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running downgrade 9905971ce75e -> , Adds Parts Table