Rename `test_asnyc_client` > `test_async_client`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yeray Diaz Diaz · committed by Yeray Diaz Diaz · parent b4ab7bb · Browse files · 2 files·+67 added−67 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+67 added−67 removed
- tests:+67 added−67 removed
Provenance
- Commit
e46ee49- Tree
111ba56- Author
Yeray Diaz Diaz <yeraydiazdiaz@gmail.com>- Committer
Yeray Diaz Diaz <yeraydiazdiaz@gmail.com>- Parent
b4ab7bb
2 files changed+67 added−67 removed
deleted:tests/client/test_asnyc_client.py-67 removed
1-import pytest2-3-import httpcore4-5-6-@pytest.mark.asyncio7-async def test_get(server):8- url = "http://127.0.0.1:8000/"9- async with httpcore.AsyncClient() as client:10- response = await client.get(url)11- assert response.status_code == 20012- assert response.text == "Hello, world!"13-14-15-@pytest.mark.asyncio16-async def test_post(server):17- url = "http://127.0.0.1:8000/"18- async with httpcore.AsyncClient() as client:19- response = await client.post(url, data=b"Hello, world!")20- assert response.status_code == 20021-22-23-@pytest.mark.asyncio24-async def test_stream_response(server):25- async with httpcore.AsyncClient() as client:26- response = await client.request("GET", "http://127.0.0.1:8000/", stream=True)27- assert response.status_code == 20028- body = await response.read()29- assert body == b"Hello, world!"30- assert response.content == b"Hello, world!"31-32-33-@pytest.mark.asyncio34-async def test_access_content_stream_response(server):35- async with httpcore.AsyncClient() as client:36- response = await client.request("GET", "http://127.0.0.1:8000/", stream=True)37- assert response.status_code == 20038- with pytest.raises(httpcore.ResponseNotRead):39- response.content40-41-42-@pytest.mark.asyncio43-async def test_stream_request(server):44- async def hello_world():45- yield b"Hello, "46- yield b"world!"47-48- async with httpcore.AsyncClient() as client:49- response = await client.request(50- "POST", "http://127.0.0.1:8000/", data=hello_world()51- )52- assert response.status_code == 20053-54-55-@pytest.mark.asyncio56-async def test_raise_for_status(server):57- async with httpcore.AsyncClient() as client:58- for status_code in (200, 400, 404, 500, 505):59- response = await client.request(60- "GET", f"http://127.0.0.1:8000/status/{status_code}"61- )62-63- if 400 <= status_code < 600:64- with pytest.raises(httpcore.exceptions.HttpError):65- response.raise_for_status()66- else:67- assert response.raise_for_status() is Noneadded:tests/client/test_async_client.py+67 added
1+import pytest2+3+import httpcore4+5+6+@pytest.mark.asyncio7+async def test_get(server):8+ url = "http://127.0.0.1:8000/"9+ async with httpcore.AsyncClient() as client:10+ response = await client.get(url)11+ assert response.status_code == 20012+ assert response.text == "Hello, world!"13+14+15+@pytest.mark.asyncio16+async def test_post(server):17+ url = "http://127.0.0.1:8000/"18+ async with httpcore.AsyncClient() as client:19+ response = await client.post(url, data=b"Hello, world!")20+ assert response.status_code == 20021+22+23+@pytest.mark.asyncio24+async def test_stream_response(server):25+ async with httpcore.AsyncClient() as client:26+ response = await client.request("GET", "http://127.0.0.1:8000/", stream=True)27+ assert response.status_code == 20028+ body = await response.read()29+ assert body == b"Hello, world!"30+ assert response.content == b"Hello, world!"31+32+33+@pytest.mark.asyncio34+async def test_access_content_stream_response(server):35+ async with httpcore.AsyncClient() as client:36+ response = await client.request("GET", "http://127.0.0.1:8000/", stream=True)37+ assert response.status_code == 20038+ with pytest.raises(httpcore.ResponseNotRead):39+ response.content40+41+42+@pytest.mark.asyncio43+async def test_stream_request(server):44+ async def hello_world():45+ yield b"Hello, "46+ yield b"world!"47+48+ async with httpcore.AsyncClient() as client:49+ response = await client.request(50+ "POST", "http://127.0.0.1:8000/", data=hello_world()51+ )52+ assert response.status_code == 20053+54+55+@pytest.mark.asyncio56+async def test_raise_for_status(server):57+ async with httpcore.AsyncClient() as client:58+ for status_code in (200, 400, 404, 500, 505):59+ response = await client.request(60+ "GET", f"http://127.0.0.1:8000/status/{status_code}"61+ )62+63+ if 400 <= status_code < 600:64+ with pytest.raises(httpcore.exceptions.HttpError):65+ response.raise_for_status()66+ else:67+ assert response.raise_for_status() is None