-
-
Notifications
You must be signed in to change notification settings - Fork 857
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
Refactor tests to use MockTransport(<handler_function>)
#1281
Conversation
and ( | ||
"Content-Length" in request_headers | ||
or "Transfer-Encoding" in request_headers | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit fiddly to explain why we're having to do this at the moment, but it's related to some of the grungy bits that need ironing out in #1253.
I'll resolve it as part of a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice indeed! 💯 👍
Refactors our test cases so that we're able to test against simple request/response handler functions.
This is actually kind of a big deal. 🤗
Everything is still passing through our really tightly defined transport API, but we get the benefits of being able to work with proper request/response instances, rather than having to build out test behaviours by scratching around with bytewise variables, raw header lists, and
httpcore.SyncIteratorStream
/httpcore.AsyncIteratorStream
instances.Still need to clean up
client/test_auth.py
using this, but have covered all the other client test modules.The implementation of
MockTransport
in thetests/utils.py
module also gives us a really good concrete case to work against for working through some of the more nitty gritty details of the request/response APIs.Really we'd like for the implementation to be as simple as...
(In fact in addition to that, we'd probably also like to end up with an API that allows
MockTransport
be usable with either sync or async clients, rather than having to have separateMockTransport
andAsyncMockTransport
classes, but let's save that conversation for another day.)The existing implementation here gives us something to work against, while tackling little parts of that incrementally. Eg. adding support for passing raw URL tuples of
(<bytes>, <bytes>, <optional int>, <bytes>)
tohttpx.URL(...)
, and also some of the details around #1253Related to #1091