diff --git a/pyproject.toml b/pyproject.toml index f5cf38c..6f9983f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,4 +72,13 @@ exclude = ["migrations", "tests"] [tool.pytest.ini_options] asyncio_mode = "auto" +# The integration test suite shares one session-scoped asyncpg engine +# (tests/conftest.py:engine) across every test, for speed — schema is +# created once instead of per test. asyncpg connections are bound to the +# event loop they were created in, so every fixture/test must run on that +# same loop; pytest-asyncio's default is a fresh loop per test, which +# breaks that assumption ("another operation is in progress" / "attached +# to a different loop"). Pinning both to "session" fixes it. +asyncio_default_fixture_loop_scope = "session" +asyncio_default_test_loop_scope = "session" testpaths = ["tests"]