Thanks to Boris's advice, I managed to find a bug in the tests. An async fixture with session visibility was declared. Which created another event_loop and led to the problem.
Here is the code with the error:
@pytest_asyncio.fixture(scope="session")
async def engine(app_database_url, migrations) -> AsyncEngine:
"""Creates a SQLAlchemy engine to interact with the database."""
engine = create_async_engine(app_database_url)
yield engine
await engine.dispose()
To fix it, just need to remove scope="session"
from the decorator.
And then it will become a foonction scope like all other fixtures and will not create its own separate event_loop