Skip to content
Myr

test_api.py

This file

Path

tests/test_api.py

73 lines · 1.8 KiB · Python

Last changed by

Seperate `content=...` and `data=...` parameters (#1266)Tom Christiebefore adoptionfeb404f

History of this file

Take it

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

Attempt to resolve test flakiness (#946)Tom Christiebefore adoptiond6b3794

lines 1–14why, one step back
1import pytest
23import httpx456def test_get(server):7 response = httpx.get(server.url)8 assert response.status_code == 2009 assert response.reason_phrase == "OK"10 assert response.text == "Hello, world!"11 assert response.http_version == "HTTP/1.1"121314def test_post(server):

Seperate `content=...` and `data=...` parameters (#1266)Tom Christiebefore adoptionfeb404f

line 15why, one step back
15 response = httpx.post(server.url, content=b"Hello, world!")

Attempt to resolve test flakiness (#946)Tom Christiebefore adoptiond6b3794

lines 16–25why, one step back
16 assert response.status_code == 200
17 assert response.reason_phrase == "OK"181920def test_post_byte_iterator(server):21 def data():22 yield b"Hello"23 yield b", "24 yield b"world!"25

Seperate `content=...` and `data=...` parameters (#1266)Tom Christiebefore adoptionfeb404f

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

Attempt to resolve test flakiness (#946)Tom Christiebefore adoptiond6b3794

lines 27–43why, one step back
27 assert response.status_code == 200
28 assert response.reason_phrase == "OK"293031def test_options(server):32 response = httpx.options(server.url)33 assert response.status_code == 20034 assert response.reason_phrase == "OK"353637def test_head(server):38 response = httpx.head(server.url)39 assert response.status_code == 20040 assert response.reason_phrase == "OK"414243def test_put(server):

Seperate `content=...` and `data=...` parameters (#1266)Tom Christiebefore adoptionfeb404f

line 44why, one step back
44 response = httpx.put(server.url, content=b"Hello, world!")

Attempt to resolve test flakiness (#946)Tom Christiebefore adoptiond6b3794

lines 45–49why, one step back
45 assert response.status_code == 200
46 assert response.reason_phrase == "OK"474849def test_patch(server):

Seperate `content=...` and `data=...` parameters (#1266)Tom Christiebefore adoptionfeb404f

line 50why, one step back
50 response = httpx.patch(server.url, content=b"Hello, world!")

Attempt to resolve test flakiness (#946)Tom Christiebefore adoptiond6b3794

lines 51–70why, one step back
51 assert response.status_code == 200
52 assert response.reason_phrase == "OK"535455def test_delete(server):56 response = httpx.delete(server.url)57 assert response.status_code == 20058 assert response.reason_phrase == "OK"596061def test_stream(server):62 with httpx.stream("GET", server.url) as response:63 response.read()6465 assert response.status_code == 20066 assert response.reason_phrase == "OK"67 assert response.text == "Hello, world!"68 assert response.http_version == "HTTP/1.1"6970

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 71why, one step back
71def test_get_invalid_url():

Map rfc3986 exceptions (#1163)Joebefore adoption45de714

line 72why, one step back
72 with pytest.raises(httpx.UnsupportedProtocol):

Type check tests (#1054)Florimond Mancabefore adoption0296c2b

line 73why, one step back
73 httpx.get("invalid://example.org")