Skip to content
Myr

test_timeouts.py

This file

Path

tests/test_timeouts.py

39 lines · 1.3 KiB · Python

Last changed by

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

History of this file

Take it

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 3why, one step back
3import httpx

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

lines 4–5why, one step back
4
5

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

line 6why, one step back
6async def test_read_timeout(server, backend):

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 7why, one step back
7 timeout = httpx.Timeout(read_timeout=1e-6)

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

line 8why, one step back
8

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 9why, one step back
9 async with httpx.Client(timeout=timeout) as client:

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

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

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

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

lines 12–13why, one step back
12
13

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

line 14why, one step back
14async def test_write_timeout(server, backend):

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 15why, one step back
15 timeout = httpx.Timeout(write_timeout=1e-6)

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

line 16why, one step back
16

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 17why, one step back
17 async with httpx.Client(timeout=timeout) as client:

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

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

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

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

lines 21–22why, one step back
21
22

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

line 23why, one step back
23async def test_connect_timeout(server, backend):

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 24why, one step back
24 timeout = httpx.Timeout(connect_timeout=1e-6)

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

line 25why, one step back
25

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 26why, one step back
26 async with httpx.Client(timeout=timeout) as client:

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

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

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

lines 28–31why, one step back
28 # See https://stackoverflow.com/questions/100841/
29 await client.get("http://10.255.255.1/")3031

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

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

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

lines 33–34why, one step back
33 pool_limits = httpx.PoolLimits(hard_limit=1)
34 timeout = httpx.Timeout(pool_timeout=1e-4)

Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a

line 35why, one step back
35

Refactor tests in the light of backend auto-detection (#615)Florimond Mancabefore adoptionab41a5d

line 36why, one step back
36 async with httpx.Client(pool_limits=pool_limits, timeout=timeout) as client:

Add Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b

line 37why, one step back
37 async with client.stream("GET", server.url):

Tighten up top-level API to only expose public API (#608)Tom Christiebefore adoptiond15dc0b

line 38why, one step back
38 with pytest.raises(httpx.PoolTimeout):

Add Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b

line 39why, one step back
39 await client.get("http://localhost:8000/")