test_requests.py
This file
Path
tests/models/test_requests.py
88 lines · 2.6 KiB · Python
Last changed by
Drop sync (#544)Tom Christiebefore adoption206c537
History of this fileTake it
The walk stopped after 200 commits: lines older than 0e8dae4 point at it.
Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 1–2why, one step back1import pytest2Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 3why, one step back3import httpxMultipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 4–6why, one step back456def test_request_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 7why, one step back7 request = httpx.Request("GET", "http://example.org")Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 8–11why, one step back8 assert repr(request) == "<Request('GET', 'http://example.org')>"91011def test_no_content():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 12why, one step back12 request = httpx.Request("GET", "http://example.org")Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 13–16why, one step back13 assert "Content-Length" not in request.headers141516def test_content_length_header():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 17why, one step back17 request = httpx.Request("POST", "http://example.org", data=b"test 123")Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 18–21why, one step back18 assert request.headers["Content-Length"] == "8"192021def test_url_encoded_data():Drop sync (#544)Tom Christiebefore adoption206c537
lines 22–24why, one step back22 request = httpx.Request("POST", "http://example.org", data={"test": "123"})23 assert request.headers["Content-Type"] == "application/x-www-form-urlencoded"24 assert request.content == b"test=123"Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 25–27why, one step back252627def test_json_encoded_data():Drop sync (#544)Tom Christiebefore adoption206c537
lines 28–30why, one step back28 request = httpx.Request("POST", "http://example.org", json={"test": 123})29 assert request.headers["Content-Type"] == "application/json"30 assert request.content == b'{"test": 123}'Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 31–33why, one step back313233def test_transfer_encoding_header():Drop sync (#544)Tom Christiebefore adoption206c537
line 34why, one step back34 async def streaming_body(data):Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 35–38why, one step back35 yield data # pragma: nocover3637 data = streaming_body(b"test 123")38Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 39why, one step back39 request = httpx.Request("POST", "http://example.org", data=data)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 40–46why, one step back40 assert "Content-Length" not in request.headers41 assert request.headers["Transfer-Encoding"] == "chunked"424344def test_override_host_header():45 headers = {"host": "1.2.3.4:80"}46Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 47why, one step back47 request = httpx.Request("GET", "http://example.org", headers=headers)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 48–53why, one step back48 assert request.headers["Host"] == "1.2.3.4:80"495051def test_override_accept_encoding_header():52 headers = {"Accept-Encoding": "identity"}53Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 54why, one step back54 request = httpx.Request("GET", "http://example.org", headers=headers)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 55–58why, one step back55 assert request.headers["Accept-Encoding"] == "identity"565758def test_override_content_length_header():Drop sync (#544)Tom Christiebefore adoption206c537
line 59why, one step back59 async def streaming_body(data):Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 60–64why, one step back60 yield data # pragma: nocover6162 data = streaming_body(b"test 123")63 headers = {"Content-Length": "8"}64Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 65why, one step back65 request = httpx.Request("POST", "http://example.org", data=data, headers=headers)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 66–70why, one step back66 assert request.headers["Content-Length"] == "8"676869def test_url():70 url = "http://example.org"Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 71why, one step back71 request = httpx.Request("GET", url)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 72–76why, one step back72 assert request.url.scheme == "http"73 assert request.url.port == 8074 assert request.url.full_path == "/"7576 url = "https://example.org/abc?foo=bar"Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 77why, one step back77 request = httpx.Request("GET", url)Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
lines 78–83why, one step back78 assert request.url.scheme == "https"79 assert request.url.port == 44380 assert request.url.full_path == "/abc?foo=bar"818283def test_invalid_urls():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 84–85why, one step back84 with pytest.raises(httpx.InvalidURL):85 httpx.Request("GET", "example.org")Multipart data values encoding (#121)ambrozicbefore adoption0e8dae4
line 86why, one step back86Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 87–88why, one step back87 with pytest.raises(httpx.InvalidURL):88 httpx.Request("GET", "http:///foo")