test_timeouts.py
This file
Path
tests/test_timeouts.py
42 lines · 1.1 KiB · Python
Last changed by
Truckin' onTom Christiebefore adoption6b60d95
History of this fileTake it
Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 1–2why, one step back1import pytest2Truckin' onTom Christiebefore adoption6b60d95
lines 3–10why, one step back3from httpcore import (4 Client,5 ConnectTimeout,6 PoolLimits,7 PoolTimeout,8 ReadTimeout,9 TimeoutConfig,10)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 11–14why, one step back111213@pytest.mark.asyncio14async def test_read_timeout(server):Truckin' onTom Christiebefore adoption6b60d95
line 15why, one step back15 timeout = TimeoutConfig(read_timeout=0.0001)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 16why, one step back16Truckin' onTom Christiebefore adoption6b60d95
lines 17–19why, one step back17 async with Client(timeout=timeout) as client:18 with pytest.raises(ReadTimeout):19 await client.get("http://127.0.0.1:8000/slow_response")Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 20–22why, one step back202122@pytest.mark.asyncioAdd ConnectTimeout testTom Christiebefore adoption74c9048
line 23why, one step back23async def test_connect_timeout(server):Truckin' onTom Christiebefore adoption6b60d95
line 24why, one step back24 timeout = TimeoutConfig(connect_timeout=0.0001)Add ConnectTimeout testTom Christiebefore adoption74c9048
line 25why, one step back25Truckin' onTom Christiebefore adoption6b60d95
lines 26–27why, one step back26 async with Client(timeout=timeout) as client:27 with pytest.raises(ConnectTimeout):Add ConnectTimeout testTom Christiebefore adoption74c9048
line 28why, one step back28 # See https://stackoverflow.com/questions/100841/Truckin' onTom Christiebefore adoption6b60d95
line 29why, one step back29 await client.get("http://10.255.255.1/")Add ConnectTimeout testTom Christiebefore adoption74c9048
lines 30–32why, one step back303132@pytest.mark.asyncioMerge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 33why, one step back33async def test_pool_timeout(server):Truckin' onTom Christiebefore adoption6b60d95
line 34why, one step back34 pool_limits = PoolLimits(hard_limit=1, pool_timeout=0.0001)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 35why, one step back35Truckin' onTom Christiebefore adoption6b60d95
lines 36–37why, one step back36 async with Client(pool_limits=pool_limits) as client:37 response = await client.get("http://127.0.0.1:8000/", stream=True)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 38why, one step back38Truckin' onTom Christiebefore adoption6b60d95
lines 39–40why, one step back39 with pytest.raises(PoolTimeout):40 await client.get("http://localhost:8000/")Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 41–42why, one step back4142 await response.read()