Skip to content
Myr

Minor test refactoring (#1242)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent e0b4528 · Browse files · 1 file+4 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−13 removed

  • tests:+4 added−13 removed

1 file+4 added−13 removed

modified:tests/test_asgi.py+4 added-13 removed
1from functools import partial21import pytest23import httpx4
19 unmodified lines
24 more_body = message.get("more_body", False)25 await send({"type": "http.response.body", "body": body, "more_body": more_body})262730async def raise_exc(scope, receive, send, exc=ValueError):31 raise exc()28async def raise_exc(scope, receive, send):29 raise RuntimeError()303132async def raise_exc_after_response(scope, receive, send):33 status = 200
1 unmodified line
35 headers = [(b"content-type", "text/plain"), (b"content-length", str(len(output)))]3637 await send({"type": "http.response.start", "status": status, "headers": headers})38 await send({"type": "http.response.body", "body": output})41 raise ValueError()39 raise RuntimeError()404142@pytest.mark.usefixtures("async_environment")43async def test_asgi():
15 unmodified lines
5960@pytest.mark.usefixtures("async_environment")61async def test_asgi_exc():62 async with httpx.AsyncClient(app=raise_exc) as client:65 with pytest.raises(ValueError):66 await client.get("http://www.example.org/")676869@pytest.mark.usefixtures("async_environment")70async def test_asgi_http_error():71 async with httpx.AsyncClient(app=partial(raise_exc, exc=RuntimeError)) as client:63 with pytest.raises(RuntimeError):64 await client.get("http://www.example.org/")656667@pytest.mark.usefixtures("async_environment")68async def test_asgi_exc_after_response():69 async with httpx.AsyncClient(app=raise_exc_after_response) as client:79 with pytest.raises(ValueError):70 with pytest.raises(RuntimeError):71 await client.get("http://www.example.org/")727374@pytest.mark.usefixtures("async_environment")
31 unmodified lines