test_timeouts.py
This file
Path
tests/test_timeouts.py
53 lines · 1.5 KiB · Python
Last changed by
http3 (#86)Tom Christiebefore adoptionc9747aa
History of this fileTake it
Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 1–2why, one step back1import pytest2http3 (#86)Tom Christiebefore adoptionc9747aa
line 3why, one step back3from http3 import (Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 4why, one step back4 AsyncClient,Truckin' onTom Christiebefore adoption6b60d95
lines 5–9why, one step back5 ConnectTimeout,6 PoolLimits,7 PoolTimeout,8 ReadTimeout,9 TimeoutConfig,Cookie support (#73)Tom Christiebefore adoptionfeae0a8
line 10why, one step back10 WriteTimeout,Truckin' onTom Christiebefore adoption6b60d95
line 11why, one step back11)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 12–15why, one step back121314@pytest.mark.asyncio15async def test_read_timeout(server):100% test coverage (#71)Tom Christiebefore adoptionfc16d31
line 16why, one step back16 timeout = TimeoutConfig(read_timeout=0.000001)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 17why, one step back17Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 18why, one step back18 async with AsyncClient(timeout=timeout) as client:Truckin' onTom Christiebefore adoption6b60d95
lines 19–20why, one step back19 with pytest.raises(ReadTimeout):20 await client.get("http://127.0.0.1:8000/slow_response")Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714
lines 21–24why, one step back212223@pytest.mark.asyncio24async def test_write_timeout(server):100% test coverage (#71)Tom Christiebefore adoptionfc16d31
line 25why, one step back25 timeout = TimeoutConfig(write_timeout=0.000001)Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714
lines 26–28why, one step back2627 async with AsyncClient(timeout=timeout) as client:28 with pytest.raises(WriteTimeout):100% test coverage (#71)Tom Christiebefore adoptionfc16d31
line 29why, one step back29 data = b"*" * 1024 * 1024 * 100Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714
line 30why, one step back30 await client.put("http://127.0.0.1:8000/slow_response", data=data)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 31–33why, one step back313233@pytest.mark.asyncioAdd ConnectTimeout testTom Christiebefore adoption74c9048
line 34why, one step back34async def test_connect_timeout(server):100% test coverage (#71)Tom Christiebefore adoptionfc16d31
line 35why, one step back35 timeout = TimeoutConfig(connect_timeout=0.000001)Add ConnectTimeout testTom Christiebefore adoption74c9048
line 36why, one step back36Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 37why, one step back37 async with AsyncClient(timeout=timeout) as client:Truckin' onTom Christiebefore adoption6b60d95
line 38why, one step back38 with pytest.raises(ConnectTimeout):Add ConnectTimeout testTom Christiebefore adoption74c9048
line 39why, one step back39 # See https://stackoverflow.com/questions/100841/Truckin' onTom Christiebefore adoption6b60d95
line 40why, one step back40 await client.get("http://10.255.255.1/")Add ConnectTimeout testTom Christiebefore adoption74c9048
lines 41–43why, one step back414243@pytest.mark.asyncioMerge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 44why, one step back44async def test_pool_timeout(server):100% test coverage (#71)Tom Christiebefore adoptionfc16d31
line 45why, one step back45 pool_limits = PoolLimits(hard_limit=1, pool_timeout=0.000001)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 46why, one step back46Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
line 47why, one step back47 async with AsyncClient(pool_limits=pool_limits) as client:Truckin' onTom Christiebefore adoption6b60d95
line 48why, one step back48 response = await client.get("http://127.0.0.1:8000/", stream=True)Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
line 49why, one step back49Truckin' onTom Christiebefore adoption6b60d95
lines 50–51why, one step back50 with pytest.raises(PoolTimeout):51 await client.get("http://localhost:8000/")Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7
lines 52–53why, one step back5253 await response.read()