Skip to content
Myr

test_timeouts.py

This file

Path

tests/test_timeouts.py

60 lines · 1.8 KiB · Python

Last changed by

Fix bug when using client without timeouts in Python 3.6 (#383)Florimond Mancabefore adoptioncadb9a4

History of this file

Take it

The walk stopped after 200 commits: lines older than 53a3e55 point at it.

Update README.mdTom Christiebefore adoption53a3e55

lines 1–2why, one step back
1import pytest
2

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 3why, one step back
3from httpx import (

Update README.mdTom Christiebefore adoption53a3e55

line 4why, one step back
4 AsyncClient,

Fix bug when using client without timeouts in Python 3.6 (#383)Florimond Mancabefore adoptioncadb9a4

line 5why, one step back
5 Client,

Update README.mdTom Christiebefore adoption53a3e55

lines 6–14why, one step back
6 ConnectTimeout,
7 PoolLimits,8 PoolTimeout,9 ReadTimeout,10 TimeoutConfig,11 WriteTimeout,12)1314

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

lines 15–16why, one step back
15async def test_read_timeout(server, backend):
16 timeout = TimeoutConfig(read_timeout=1e-6)

Update README.mdTom Christiebefore adoption53a3e55

line 17why, one step back
17

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 18why, one step back
18 async with AsyncClient(timeout=timeout, backend=backend) as client:

Update README.mdTom Christiebefore adoption53a3e55

line 19why, one step back
19 with pytest.raises(ReadTimeout):

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 20why, one step back
20 await client.get(server.url.copy_with(path="/slow_response"))

Update README.mdTom Christiebefore adoption53a3e55

lines 21–22why, one step back
21
22

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

lines 23–24why, one step back
23async def test_write_timeout(server, backend):
24 timeout = TimeoutConfig(write_timeout=1e-6)

Update README.mdTom Christiebefore adoption53a3e55

line 25why, one step back
25

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 26why, one step back
26 async with AsyncClient(timeout=timeout, backend=backend) as client:

Update README.mdTom Christiebefore adoption53a3e55

lines 27–28why, one step back
27 with pytest.raises(WriteTimeout):
28 data = b"*" * 1024 * 1024 * 100

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 29why, one step back
29 await client.put(server.url.copy_with(path="/slow_response"), data=data)

Update README.mdTom Christiebefore adoption53a3e55

lines 30–31why, one step back
30
31

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

lines 32–33why, one step back
32async def test_connect_timeout(server, backend):
33 timeout = TimeoutConfig(connect_timeout=1e-6)

Update README.mdTom Christiebefore adoption53a3e55

line 34why, one step back
34

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 35why, one step back
35 async with AsyncClient(timeout=timeout, backend=backend) as client:

Update README.mdTom Christiebefore adoption53a3e55

lines 36–40why, one step back
36 with pytest.raises(ConnectTimeout):
37 # See https://stackoverflow.com/questions/100841/38 await client.get("http://10.255.255.1/")3940

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 41why, one step back
41async def test_pool_timeout(server, backend):

Add trio concurrency backend (#276)Florimond Mancabefore adoption08355c6

line 42why, one step back
42 pool_limits = PoolLimits(hard_limit=1, pool_timeout=1e-4)

Update README.mdTom Christiebefore adoption53a3e55

line 43why, one step back
43

Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058

line 44why, one step back
44 async with AsyncClient(pool_limits=pool_limits, backend=backend) as client:

Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280

line 45why, one step back
45 response = await client.get(server.url, stream=True)

Update README.mdTom Christiebefore adoption53a3e55

lines 46–50why, one step back
46
47 with pytest.raises(PoolTimeout):48 await client.get("http://localhost:8000/")4950 await response.read()

Fix bug when using client without timeouts in Python 3.6 (#383)Florimond Mancabefore adoptioncadb9a4

lines 51–60why, one step back
51
5253def test_sync_infinite_timeout(server):54 """Regression test for a bug that occurred under Python 3.6.5556 See: https://github.com/encode/httpx/issues/38257 """58 no_timeout = TimeoutConfig()59 with Client(timeout=no_timeout) as client:60 client.get(server.url.copy_with(path="/slow_response/50"))