Skip to content

Commit 2b4ea3f

Browse files
committed
fix(e2e): add module-scoped event_loop fixture
Add event_loop fixture with module scope to support module-scoped async fixtures. This is required by pytest-asyncio when using async fixtures with scope='module'.
1 parent 98dc170 commit 2b4ea3f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/e2e/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
model inference and database execution.
66
"""
77

8+
import asyncio
89
import os
910
from collections.abc import AsyncGenerator
1011
from typing import Any
@@ -23,6 +24,24 @@
2324
from db.schema import ColumnInfo, SchemaInfo, TableInfo
2425
from tests.e2e.seed_data import E2E_TEST_DATA, seed_database
2526

27+
28+
# =============================================================================
29+
# Event Loop Fixture for Module-Scoped Async Fixtures
30+
# =============================================================================
31+
32+
33+
@pytest.fixture(scope="module")
34+
def event_loop() -> asyncio.AbstractEventLoop:
35+
"""
36+
Create an event loop for module-scoped async fixtures.
37+
38+
pytest-asyncio requires an event_loop fixture with the same scope
39+
as any async fixtures that need it.
40+
"""
41+
loop = asyncio.new_event_loop()
42+
yield loop
43+
loop.close()
44+
2645
# =============================================================================
2746
# Environment Configuration
2847
# =============================================================================

0 commit comments

Comments
 (0)