test_timeouts.py
This file
Path
tests/test_timeouts.py
35 lines · 1.1 KiB · Python
Last changed by
Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
History of this fileTake it
1import pytest23import httpcore456@pytest.mark.asyncio7async def test_read_timeout(server):8 timeout = httpcore.TimeoutConfig(read_timeout=0.0001)910 async with httpcore.ConnectionPool(timeout=timeout) as http:11 with pytest.raises(httpcore.ReadTimeout):12 await http.request("GET", "http://127.0.0.1:8000/slow_response")131415@pytest.mark.asyncio16async def test_connect_timeout(server):17 timeout = httpcore.TimeoutConfig(connect_timeout=0.0001)1819 async with httpcore.ConnectionPool(timeout=timeout) as http:20 with pytest.raises(httpcore.ConnectTimeout):21 # See https://stackoverflow.com/questions/100841/22 await http.request("GET", "http://10.255.255.1/")232425@pytest.mark.asyncio26async def test_pool_timeout(server):27 limits = httpcore.PoolLimits(hard_limit=1, pool_timeout=0.0001)2829 async with httpcore.ConnectionPool(limits=limits) as http:30 response = await http.request("GET", "http://127.0.0.1:8000/", stream=True)3132 with pytest.raises(httpcore.PoolTimeout):33 await http.request("GET", "http://localhost:8000/")3435 await response.read()