test_api.py
This file
Path
tests/test_api.py
83 lines · 2.1 KiB · Python
Last changed by
Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8
History of this fileTake it
The walk stopped after 200 commits: lines older than 5dc646f point at it.
Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 1–5why, one step back1import pytest23import httpx45Drop sync (#544)Tom Christiebefore adoption206c537
lines 6–8why, one step back6@pytest.mark.asyncio7async def test_get(server):8 response = await httpx.get(server.url)Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 9–14why, one step back9 assert response.status_code == 20010 assert response.reason_phrase == "OK"11 assert response.text == "Hello, world!"12 assert response.http_version == "HTTP/1.1"1314Drop sync (#544)Tom Christiebefore adoption206c537
lines 15–17why, one step back15@pytest.mark.asyncio16async def test_post(server):17 response = await httpx.post(server.url, data=b"Hello, world!")Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 18–21why, one step back18 assert response.status_code == 20019 assert response.reason_phrase == "OK"2021Drop sync (#544)Tom Christiebefore adoption206c537
lines 22–24why, one step back22@pytest.mark.asyncio23async def test_post_byte_iterator(server):24 async def data():Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 25–28why, one step back25 yield b"Hello"26 yield b", "27 yield b"world!"28Drop sync (#544)Tom Christiebefore adoption206c537
line 29why, one step back29 response = await httpx.post(server.url, data=data())Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 30–33why, one step back30 assert response.status_code == 20031 assert response.reason_phrase == "OK"3233Drop sync (#544)Tom Christiebefore adoption206c537
lines 34–36why, one step back34@pytest.mark.asyncio35async def test_options(server):36 response = await httpx.options(server.url)Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 37–40why, one step back37 assert response.status_code == 20038 assert response.reason_phrase == "OK"3940Drop sync (#544)Tom Christiebefore adoption206c537
lines 41–43why, one step back41@pytest.mark.asyncio42async def test_head(server):43 response = await httpx.head(server.url)Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 44–47why, one step back44 assert response.status_code == 20045 assert response.reason_phrase == "OK"4647Drop sync (#544)Tom Christiebefore adoption206c537
lines 48–50why, one step back48@pytest.mark.asyncio49async def test_put(server):50 response = await httpx.put(server.url, data=b"Hello, world!")Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 51–54why, one step back51 assert response.status_code == 20052 assert response.reason_phrase == "OK"5354Drop sync (#544)Tom Christiebefore adoption206c537
lines 55–57why, one step back55@pytest.mark.asyncio56async def test_patch(server):57 response = await httpx.patch(server.url, data=b"Hello, world!")Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 58–61why, one step back58 assert response.status_code == 20059 assert response.reason_phrase == "OK"6061Drop sync (#544)Tom Christiebefore adoption206c537
lines 62–64why, one step back62@pytest.mark.asyncio63async def test_delete(server):64 response = await httpx.delete(server.url)Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
lines 65–68why, one step back65 assert response.status_code == 20066 assert response.reason_phrase == "OK"6768Drop sync (#544)Tom Christiebefore adoption206c537
line 69why, one step back69@pytest.mark.asyncioAdd Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b
lines 70–71why, one step back70async def test_stream(server):71 async with httpx.stream("GET", server.url) as response:Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8
line 72why, one step back72 await response.aread()Add Client.stream() method. (#600)Tom Christiebefore adoption8d8ea8b
lines 73–80why, one step back7374 assert response.status_code == 20075 assert response.reason_phrase == "OK"76 assert response.text == "Hello, world!"77 assert response.http_version == "HTTP/1.1"787980@pytest.mark.asyncioDrop sync (#544)Tom Christiebefore adoption206c537
line 81why, one step back81async def test_get_invalid_url(server):Adding params to Client (#372)Tyrel Souzabefore adoption5dc646f
line 82why, one step back82 with pytest.raises(httpx.InvalidURL):Drop sync (#544)Tom Christiebefore adoption206c537
line 83why, one step back83 await httpx.get("invalid://example.org")