Closed
Description
Minimal example to reproduce:
from aiohttp.client import ClientSession
import pytest
@pytest.fixture
async def session():
session = ClientSession()
yield session
await session.close()
@pytest.mark.asyncio
async def test_aiohttp(session):
async with session.get('http://example.com/') as response:
pass
The test output:
============================================= FAILURES =============================================
___________________________________________ test_aiohttp ___________________________________________
Traceback (most recent call last):
File "/usr/src/tests/test_aiohttp.py", line 16, in test_aiohttp
async with session.get('http://example.com/') as response:
File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 426, in _request
with timer:
File "/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 579, in __enter__
raise RuntimeError('Timeout context manager should be used '
RuntimeError: Timeout context manager should be used inside a task
===================================== short test summary info ======================================
FAILED tests/test_aiohttp.py::test_aiohttp - RuntimeError: Timeout context manager should be used...
======================================== 1 failed in 0.17s =========================================
Works fine with 0.10.0 or when session is created directly in the test instead of fixture.
Metadata
Metadata
Assignees
Labels
No labels