mirror of
https://github.com/rommapp/romm.git
synced 2026-06-30 07:45:52 +00:00
Create separate `tests/` folder for all tests. This will also simplify not copying tests code into the Docker image.
19 lines
466 B
Python
19 lines
466 B
Python
from contextvars import ContextVar
|
|
|
|
import aiohttp
|
|
import pytest_asyncio
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def mock_ctx_aiohttp_session():
|
|
"""Create a real aiohttp session for integration tests."""
|
|
session = aiohttp.ClientSession()
|
|
ctx_aiohttp_session: ContextVar[aiohttp.ClientSession] = ContextVar(
|
|
"aiohttp_session"
|
|
)
|
|
ctx_aiohttp_session.set(session)
|
|
try:
|
|
yield ctx_aiohttp_session
|
|
finally:
|
|
await session.close()
|