Skip to content

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

Merged
lovelydinosaur merged 2 commits into
masterfrom
mock-transport-await-me-maybe
Feb 17, 2021
Merged

Allow handler to optionally be async when MockTransport is used with AsyncClient#1449
lovelydinosaur merged 2 commits into
masterfrom
mock-transport-await-me-maybe

Conversation

@lovelydinosaur

Copy link
Copy Markdown
Contributor

Prompted by #1401 (comment)

Allow usages like...

asyncdefhello_world(request):
returnhttpx.Response(200, text="Hello, world!")
transport=httpx.MockTransport(hello_world)
asyncwithhttpx.AsyncClient(transport=transport) asclient:
response=awaitclient.get("https://www.example.com")
assertresponse.status_code==200assertresponse.text=="Hello, world!"

@lovelydinosaurlovelydinosaur added this to the v0.17 milestone Jan 8, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lovelydinosaur@florimondmanca