Skip to content
Myr

test_timeouts.py

This file

Path

tests/test_timeouts.py

49 lines · 1.5 KiB · Python

Last changed by

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

History of this file

Take it

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

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

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

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

Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0

line 4why, one step back
4 AsyncClient,

Truckin' onTom Christiebefore adoption6b60d95

lines 5–9why, one step back
5 ConnectTimeout,
6 PoolLimits,7 PoolTimeout,8 ReadTimeout,9 TimeoutConfig,

Cookie support (#73)Tom Christiebefore adoptionfeae0a8

line 10why, one step back
10 WriteTimeout,

Truckin' onTom Christiebefore adoption6b60d95

line 11why, one step back
11)

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 12–13why, one step back
12
13

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

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

line 16why, one step back
16

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

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

Truckin' onTom Christiebefore adoption6b60d95

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

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

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

Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714

lines 20–21why, one step back
20
21

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

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

Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714

line 24why, one step back
24

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

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

Add test for write timeout error (#67)Yeray Diaz Diazbefore adoptionb8b3714

line 26why, one step back
26 with pytest.raises(WriteTimeout):

100% test coverage (#71)Tom Christiebefore adoptionfc16d31

line 27why, one step back
27 data = b"*" * 1024 * 1024 * 100

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

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 29–30why, one step back
29
30

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

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

line 33why, one step back
33

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

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

Truckin' onTom Christiebefore adoption6b60d95

line 35why, one step back
35 with pytest.raises(ConnectTimeout):

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

line 36why, one step back
36 # See https://stackoverflow.com/questions/100841/

Truckin' onTom Christiebefore adoption6b60d95

line 37why, one step back
37 await client.get("http://10.255.255.1/")

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 38–39why, one step back
38
39

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

lines 40–41why, one step back
40async def test_pool_timeout(server, backend):
41 pool_limits = PoolLimits(hard_limit=1, pool_timeout=1e-6)

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

line 42why, one step back
42

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

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

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

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

line 45why, one step back
45

Truckin' onTom Christiebefore adoption6b60d95

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

Carefulness with encoding everywhereTom Christiebefore adoptione1ecb36

lines 48–49why, one step back
48
49 await response.read()