Skip to content

Fix Studio Tests CI: async event loop error in backend auth tests#39

Merged
AlanFokCo merged 2 commits into
mainfrom
copilot/fix-github-ci-actions
May 28, 2026
Merged

Fix Studio Tests CI: async event loop error in backend auth tests#39
AlanFokCo merged 2 commits into
mainfrom
copilot/fix-github-ci-actions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

Studio Tests / Backend failing on both Python 3.10 and 3.11 with RuntimeError: There is no current event loop in thread 'MainThread' — all 4 TestAuthEndpoints tests erroring out.

Root cause: the client fixture used asyncio.get_event_loop().run_until_complete() to set up the DB, which has been broken since Python 3.10 deprecated implicit event loop creation.

Changes

  • web_strategy_studio/backend/tests/test_auth.py — Convert client from a sync fixture to an async fixture; replace get_event_loop().run_until_complete() with direct await; use async with AsyncClient(...) for proper lifecycle; dispose engine after yield
  • web_strategy_studio/backend/pyproject.toml — Add asyncio_mode = "auto" to pytest config so async fixtures are handled without per-fixture decoration
# Before (broken on 3.10+)
@pytest.fixture
def client(self, tmp_path):
    asyncio.get_event_loop().run_until_complete(setup_db())
    return AsyncClient(...)

# After
@pytest.fixture
async def client(self, tmp_path):
    async with new_engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)
    async with AsyncClient(...) as ac:
        yield ac
    await new_engine.dispose()

All 141 backend tests pass.

Copilot AI added 2 commits May 28, 2026 11:31
Convert sync client fixture to async fixture, use pytest-asyncio auto
mode, and properly manage AsyncClient lifecycle with async context manager.
@AlanFokCo AlanFokCo marked this pull request as ready for review May 28, 2026 11:36
@AlanFokCo AlanFokCo merged commit 0c50fed into main May 28, 2026
@AlanFokCo AlanFokCo deleted the copilot/fix-github-ci-actions branch May 28, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants