Skip to content
Myr

test_api.py

This file

Path

tests/test_api.py

74 lines · 1.8 KiB · Python

Last changed by

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

History of this file

Take it

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

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 1–5why, one step back
1import pytest
23import httpx45

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 6–7why, one step back
6def test_get(server):
7 response = httpx.get(server.url)

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 8–13why, one step back
8 assert response.status_code == 200
9 assert response.reason_phrase == "OK"10 assert response.text == "Hello, world!"11 assert response.http_version == "HTTP/1.1"1213

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 14–15why, one step back
14def test_post(server):
15 response = httpx.post(server.url, data=b"Hello, world!")

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 16–19why, one step back
16 assert response.status_code == 200
17 assert response.reason_phrase == "OK"1819

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 20–21why, one step back
20def test_post_byte_iterator(server):
21 def data():

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 22–25why, one step back
22 yield b"Hello"
23 yield b", "24 yield b"world!"25

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

line 26why, one step back
26 response = httpx.post(server.url, data=data())

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 27–30why, one step back
27 assert response.status_code == 200
28 assert response.reason_phrase == "OK"2930

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 31–32why, one step back
31def test_options(server):
32 response = httpx.options(server.url)

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 33–36why, one step back
33 assert response.status_code == 200
34 assert response.reason_phrase == "OK"3536

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 37–38why, one step back
37def test_head(server):
38 response = httpx.head(server.url)

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 39–42why, one step back
39 assert response.status_code == 200
40 assert response.reason_phrase == "OK"4142

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 43–44why, one step back
43def test_put(server):
44 response = httpx.put(server.url, data=b"Hello, world!")

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 45–48why, one step back
45 assert response.status_code == 200
46 assert response.reason_phrase == "OK"4748

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 49–50why, one step back
49def test_patch(server):
50 response = httpx.patch(server.url, data=b"Hello, world!")

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 51–54why, one step back
51 assert response.status_code == 200
52 assert response.reason_phrase == "OK"5354

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 55–56why, one step back
55def test_delete(server):
56 response = httpx.delete(server.url)

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 57–60why, one step back
57 assert response.status_code == 200
58 assert response.reason_phrase == "OK"5960

Reintroduce sync API. (#735)Tom Christiebefore adoptionee37a76

lines 61–63why, one step back
61def test_stream(server):
62 with httpx.stream("GET", server.url) as response:63 response.read()

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

lines 64–71why, one step back
64
65 assert response.status_code == 20066 assert response.reason_phrase == "OK"67 assert response.text == "Hello, world!"68 assert response.http_version == "HTTP/1.1"697071@pytest.mark.asyncio

Drop `iterate_in_threadpool` and `iterate` (#564)Tom Christiebefore adoptionb1393ec

lines 72–74why, one step back
72async def test_get_invalid_url(server):
73 with pytest.raises(httpx.InvalidURL):74 await httpx.get("invalid://example.org")