test_timeouts.py
This file
Path
tests/test_timeouts.py
57 lines · 1.9 KiB · Python
Last changed by
Rename PoolLimits to Limits (#1113)Florimond Mancabefore adoptionf67e925
History of this fileTake it
The walk stopped after 200 commits: lines older than c5037f0 point at it.
Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
lines 1–7why, one step back1import pytest23import httpx456@pytest.mark.usefixtures("async_environment")7async def test_read_timeout(server):Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5
line 8why, one step back8 timeout = httpx.Timeout(None, read=1e-6)Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
lines 9–16why, one step back910 async with httpx.AsyncClient(timeout=timeout) as client:11 with pytest.raises(httpx.ReadTimeout):12 await client.get(server.url.copy_with(path="/slow_response"))131415@pytest.mark.usefixtures("async_environment")16async def test_write_timeout(server):Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5
line 17why, one step back17 timeout = httpx.Timeout(None, write=1e-6)Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
lines 18–26why, one step back1819 async with httpx.AsyncClient(timeout=timeout) as client:20 with pytest.raises(httpx.WriteTimeout):21 data = b"*" * 1024 * 1024 * 10022 await client.put(server.url.copy_with(path="/slow_response"), data=data)232425@pytest.mark.usefixtures("async_environment")26async def test_connect_timeout(server):Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5
line 27why, one step back27 timeout = httpx.Timeout(None, connect=1e-6)Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
lines 28–36why, one step back2829 async with httpx.AsyncClient(timeout=timeout) as client:30 with pytest.raises(httpx.ConnectTimeout):31 # See https://stackoverflow.com/questions/100841/32 await client.get("http://10.255.255.1/")333435@pytest.mark.usefixtures("async_environment")36async def test_pool_timeout(server):Rename PoolLimits to Limits (#1113)Florimond Mancabefore adoptionf67e925
line 37why, one step back37 limits = httpx.Limits(max_connections=1)Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5
line 38why, one step back38 timeout = httpx.Timeout(None, pool=1e-4)Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
line 39why, one step back39Rename PoolLimits to Limits (#1113)Florimond Mancabefore adoptionf67e925
line 40why, one step back40 async with httpx.AsyncClient(limits=limits, timeout=timeout) as client:Drop per-request 'cert'/'verify'/'trust_env', and 'stream=bool' arguments (#730)Tom Christiebefore adoptionc5037f0
lines 41–43why, one step back41 async with client.stream("GET", server.url):42 with pytest.raises(httpx.PoolTimeout):43 await client.get("http://localhost:8000/")Switch to more concise Timeout parameters (#1111)Florimond Mancabefore adoption26cd4f5
lines 44–57why, one step back444546def test_deprecated_verbose_timeout_params():47 with pytest.warns(DeprecationWarning):48 httpx.Timeout(None, read_timeout=1.0)4950 with pytest.warns(DeprecationWarning):51 httpx.Timeout(None, write_timeout=1.0)5253 with pytest.warns(DeprecationWarning):54 httpx.Timeout(None, connect_timeout=1.0)5556 with pytest.warns(DeprecationWarning):57 httpx.Timeout(None, pool_timeout=1.0)