test_timeouts.py
This file
Path
tests/test_timeouts.py
35 lines · 1.1 KiB · Python
Last changed by
Merge branch 'master' into wait-for-connection-closeTom Christiebefore adoption20bc1f3
History of this fileTake it
Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 1–15why, one step back1import 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.asyncioAdd ConnectTimeout testTom Christiebefore adoption74c9048
lines 16–25why, one step back16async 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.asyncioMerge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 26why, one step back26async def test_pool_timeout(server):Merge branch 'master' into wait-for-connection-closeTom Christiebefore adoption20bc1f3
line 27why, one step back27 limits = httpcore.PoolLimits(hard_limit=1, pool_timeout=0.0001)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 28why, one step back28Merge branch 'master' into wait-for-connection-closeTom Christiebefore adoption20bc1f3
line 29why, one step back29 async with httpcore.ConnectionPool(limits=limits) as http:Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 30–35why, one step back30 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()