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

Easier support for HTTPX MockTransport #118

Merged
merged 3 commits into from
Nov 26, 2020
Merged

Easier support for HTTPX MockTransport #118

merged 3 commits into from
Nov 26, 2020

Conversation

lundberg
Copy link
Owner

@lundberg lundberg commented Nov 26, 2020

Adds support for passing using arg when instantiating MockRouter to define what patcher to use, or to disable patching completely.

This allows easier usage of future HTTPX MockTransport, if you don't want RESPX to patch the httpcore transports.

import httpx
import respx


mock_router = respx.MockRouter(using=None)
route = mock_router.get("https://example.org/") % 204

transport = httpx.MockTransport(mock_router.handler)

with httpx.Client(transport=transport) as client:
    response = client.get("https://example.org/")
    assert response.status_code == 204
    assert route.called

@lundberg lundberg changed the title Add support for optional patching in MockRouter Add easier support for HTTPX MockTransport Nov 26, 2020
@lundberg lundberg changed the title Add easier support for HTTPX MockTransport Easier support for HTTPX MockTransport Nov 26, 2020
@lundberg lundberg merged commit c58df1e into master Nov 26, 2020
@lundberg lundberg deleted the using branch November 26, 2020 15:59
lundberg added a commit that referenced this pull request Nov 26, 2020
Added
- Easier support for using HTTPX MockTransport. (PR #118)
- Support mixed case for `method__in` and `scheme__in` pattern lookups. (PR #113)

Fixed
- Handle missing path in URL pattern (PR #113)

Changed
- Refactored internal mocking vs `MockTransport`. (PR #112)

Removed
- Dropped raw request support when parsing patterns (PR #113)
@lundberg
Copy link
Owner Author

Related HTTPX issue 1303

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