test_timeouts.py
This file
Path
tests/test_timeouts.py
42 lines · 1.1 KiB · Python
Last changed by
Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
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
line 3why, one step back3from httpcore import (Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 4why, one step back4 AsyncClient,Truckin' onTom Christiebefore adoption6b60d95
lines 5–10why, one step back5 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 back16Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 17why, one step back17 async with AsyncClient(timeout=timeout) as client:Truckin' onTom Christiebefore adoption6b60d95
lines 18–19why, one step back18 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 back25Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 26why, one step back26 async with AsyncClient(timeout=timeout) as client:Truckin' onTom Christiebefore adoption6b60d95
line 27why, one step back27 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 back35Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 36why, one step back36 async with AsyncClient(pool_limits=pool_limits) as client:Truckin' onTom Christiebefore adoption6b60d95
line 37why, one step back37 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()