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

Don't patch ASGI and WSGI transports by default #131

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

lundberg
Copy link
Owner

@lundberg lundberg commented Feb 5, 2021

When using HTTPX as test client, i.e. testing FastAPI, you'll pass your asgi app to the client.

Therefore RESPX shouldn't patch those app transports by default.

This PR removes the asgi and wsgi transports from the default list of patch targets, but also adds support for manually adding and removing transports of your choice, i.e. re-adding any of those or adding a custom 3:rd party transport.

If anyone needs the current behaviour, patching asgi and/or wsgi transports, one now needs to do:

from respx.mocks import HTTPCoreMocker


HTTPCoreMocker.add_targets(
    "httpx._transports.asgi.ASGITransport",
    "httpx._transports.wsgi.WSGITransport",
)

@lundberg lundberg force-pushed the dont-patch-asgi-wsgi branch from 8159fcf to ce044a5 Compare March 2, 2021 11:13
@lundberg lundberg merged commit 01ad341 into master Mar 2, 2021
@lundberg lundberg deleted the dont-patch-asgi-wsgi branch March 2, 2021 11:15
lundberg added a commit that referenced this pull request Apr 27, 2021
Changed
- Require `HTTPX` 0.18.0 and implement the new transport API. (PR #142)
- Removed ASGI and WSGI transports from httpcore patch list. (PR #131)
- Don't pre-read mocked async resposne streams. (PR #136)

Fixed
- Fixed syntax highlighting in docs, thanks @florimondmanca. (PR #134)
- Type check `route.return_value`, thanks @tzing. (PR #133)
- Fixed a typo in the docs, thanks @lewoudar. (PR #139)

Added
- Added support for adding/removing patch targets. (PR #131)
- Added test session for python 3.10. (PR #140)
- Added RESPX Mock Swallowtail to README. (PR #128)
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.

1 participant