Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow handler to optionally be async when MockTransport is used with AsyncClient #1449

Merged
merged 2 commits into from
Feb 17, 2021

Conversation

tomchristie
Copy link
Member

Prompted by #1401 (comment)

Allow usages like...

async def hello_world(request):
    return httpx.Response(200, text="Hello, world!")

transport = httpx.MockTransport(hello_world)

async with httpx.AsyncClient(transport=transport) as client:
    response = await client.get("https://www.example.com")
    assert response.status_code == 200
    assert response.text == "Hello, world!"

@tomchristie tomchristie added this to the v0.17 milestone Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants