test_api.py
This file
Path
tests/test_api.py
87 lines · 2.2 KiB · Python
Last changed by
Typing: enable disallow_untyped_calls (#2479)Martijn Pietersbefore adoption933551c
History of this fileTake it
The walk stopped after 200 commits: lines older than 885314a point at it.
Typing: enable disallow_untyped_calls (#2479)Martijn Pietersbefore adoption933551c
lines 1–2why, one step back1import typing2Bump wheel from 0.36.2 to 0.37.0 (#1878)dependabot[bot]before adoption885314a
lines 3–22why, one step back3import pytest45import httpx678def test_get(server):9 response = httpx.get(server.url)10 assert response.status_code == 20011 assert response.reason_phrase == "OK"12 assert response.text == "Hello, world!"13 assert response.http_version == "HTTP/1.1"141516def test_post(server):17 response = httpx.post(server.url, content=b"Hello, world!")18 assert response.status_code == 20019 assert response.reason_phrase == "OK"202122def test_post_byte_iterator(server):Typing: enable disallow_untyped_calls (#2479)Martijn Pietersbefore adoption933551c
line 23why, one step back23 def data() -> typing.Iterator[bytes]:Bump wheel from 0.36.2 to 0.37.0 (#1878)dependabot[bot]before adoption885314a
lines 24–32why, one step back24 yield b"Hello"25 yield b", "26 yield b"world!"2728 response = httpx.post(server.url, content=data())29 assert response.status_code == 20030 assert response.reason_phrase == "OK"3132Fix for stream uploads that subclass SyncByteStream/AsyncByteStream (#2016)Tom Christiebefore adoptionb7dc0c3
lines 33–44why, one step back33def test_post_byte_stream(server):34 class Data(httpx.SyncByteStream):35 def __iter__(self):36 yield b"Hello"37 yield b", "38 yield b"world!"3940 response = httpx.post(server.url, content=Data())41 assert response.status_code == 20042 assert response.reason_phrase == "OK"4344Bump wheel from 0.36.2 to 0.37.0 (#1878)dependabot[bot]before adoption885314a
lines 45–87why, one step back45def test_options(server):46 response = httpx.options(server.url)47 assert response.status_code == 20048 assert response.reason_phrase == "OK"495051def test_head(server):52 response = httpx.head(server.url)53 assert response.status_code == 20054 assert response.reason_phrase == "OK"555657def test_put(server):58 response = httpx.put(server.url, content=b"Hello, world!")59 assert response.status_code == 20060 assert response.reason_phrase == "OK"616263def test_patch(server):64 response = httpx.patch(server.url, content=b"Hello, world!")65 assert response.status_code == 20066 assert response.reason_phrase == "OK"676869def test_delete(server):70 response = httpx.delete(server.url)71 assert response.status_code == 20072 assert response.reason_phrase == "OK"737475def test_stream(server):76 with httpx.stream("GET", server.url) as response:77 response.read()7879 assert response.status_code == 20080 assert response.reason_phrase == "OK"81 assert response.text == "Hello, world!"82 assert response.http_version == "HTTP/1.1"838485def test_get_invalid_url():86 with pytest.raises(httpx.UnsupportedProtocol):87 httpx.get("invalid://example.org")