test_api.py
This file
Path
tests/test_api.py
63 lines · 1.5 KiB · Python
Last changed by
Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
History of this fileTake it
Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 1–2why, one step back1import pytest2Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 3why, one step back3import httpxAdd top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 4–6why, one step back456def test_get(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 7why, one step back7 response = httpx.get(server.url)Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 8–10why, one step back8 assert response.status_code == 2009 assert response.reason_phrase == "OK"10 assert response.text == "Hello, world!"Force HTTP/1.1 on short-lived connections (#284)Seth Michael Larsonbefore adoptione7aa6d6
line 11why, one step back11 assert response.http_version == "HTTP/1.1"Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 12–14why, one step back121314def test_post(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 15why, one step back15 response = httpx.post(server.url, data=b"Hello, world!")Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 16–19why, one step back16 assert response.status_code == 20017 assert response.reason_phrase == "OK"1819Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 20–25why, one step back20def test_post_byte_iterator(server):21 def data():22 yield b"Hello"23 yield b", "24 yield b"world!"25Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 26why, one step back26 response = httpx.post(server.url, data=data())Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
lines 27–30why, one step back27 assert response.status_code == 20028 assert response.reason_phrase == "OK"2930Add top-level API (#75)Tom Christiebefore adoptionfc627f3
line 31why, one step back31def test_options(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 32why, one step back32 response = httpx.options(server.url)Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 33–37why, one step back33 assert response.status_code == 20034 assert response.reason_phrase == "OK"353637def test_head(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 38why, one step back38 response = httpx.head(server.url)Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 39–43why, one step back39 assert response.status_code == 20040 assert response.reason_phrase == "OK"414243def test_put(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 44why, one step back44 response = httpx.put(server.url, data=b"Hello, world!")Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 45–49why, one step back45 assert response.status_code == 20046 assert response.reason_phrase == "OK"474849def test_patch(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 50why, one step back50 response = httpx.patch(server.url, data=b"Hello, world!")Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 51–55why, one step back51 assert response.status_code == 20052 assert response.reason_phrase == "OK"535455def test_delete(server):Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 56why, one step back56 response = httpx.delete(server.url)Add top-level API (#75)Tom Christiebefore adoptionfc627f3
lines 57–58why, one step back57 assert response.status_code == 20058 assert response.reason_phrase == "OK"Minor tweaks in line with requests behavior (#110)Tom Christiebefore adoptionfe1f9ed
lines 59–61why, one step back596061def test_get_invalid_url(server):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 62–63why, one step back62 with pytest.raises(httpx.InvalidURL):63 httpx.get("invalid://example.org")