test_api.py
This file
Path
tests/test_api.py
73 lines · 1.8 KiB · Python
Last changed by
Type check tests (#1054)Florimond Mancabefore adoption0296c2b
History of this fileTake it
The walk stopped after 200 commits: lines older than 2c4a1dd point at it.
Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 1–5why, one step back1import pytest23import httpx45Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 6–7why, one step back6def test_get(server):7 response = httpx.get(server.url)Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 8–13why, one step back8 assert response.status_code == 2009 assert response.reason_phrase == "OK"10 assert response.text == "Hello, world!"11 assert response.http_version == "HTTP/1.1"1213Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 14–15why, one step back14def test_post(server):15 response = httpx.post(server.url, data=b"Hello, world!")Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 16–19why, one step back16 assert response.status_code == 20017 assert response.reason_phrase == "OK"1819Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 20–21why, one step back20def test_post_byte_iterator(server):21 def data():Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 22–25why, one step back22 yield b"Hello"23 yield b", "24 yield b"world!"25Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
line 26why, one step back26 response = httpx.post(server.url, data=data())Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 27–30why, one step back27 assert response.status_code == 20028 assert response.reason_phrase == "OK"2930Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 31–32why, one step back31def test_options(server):32 response = httpx.options(server.url)Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 33–36why, one step back33 assert response.status_code == 20034 assert response.reason_phrase == "OK"3536Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 37–38why, one step back37def test_head(server):38 response = httpx.head(server.url)Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 39–42why, one step back39 assert response.status_code == 20040 assert response.reason_phrase == "OK"4142Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 43–44why, one step back43def test_put(server):44 response = httpx.put(server.url, data=b"Hello, world!")Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 45–48why, one step back45 assert response.status_code == 20046 assert response.reason_phrase == "OK"4748Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 49–50why, one step back49def test_patch(server):50 response = httpx.patch(server.url, data=b"Hello, world!")Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 51–54why, one step back51 assert response.status_code == 20052 assert response.reason_phrase == "OK"5354Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 55–56why, one step back55def test_delete(server):56 response = httpx.delete(server.url)Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 57–60why, one step back57 assert response.status_code == 20058 assert response.reason_phrase == "OK"5960Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76
lines 61–63why, one step back61def test_stream(server):62 with httpx.stream("GET", server.url) as response:63 response.read()Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
lines 64–70why, one step back6465 assert response.status_code == 20066 assert response.reason_phrase == "OK"67 assert response.text == "Hello, world!"68 assert response.http_version == "HTTP/1.1"6970Type check tests (#1054)Florimond Mancabefore adoption0296c2b
line 71why, one step back71def test_get_invalid_url():Drop OpenConnection (#700)Tom Christiebefore adoption2c4a1dd
line 72why, one step back72 with pytest.raises(httpx.InvalidURL):Type check tests (#1054)Florimond Mancabefore adoption0296c2b
line 73why, one step back73 httpx.get("invalid://example.org")