Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
LITE-33583: Runtime floor to Python 3.10 and modernize http toolchain#86
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3ba7d6a22e568fc14e8ee6a26429File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,6 +10,7 @@ | ||
| import responses | ||
| from pytest import MonkeyPatch | ||
| from pytest_httpx import HTTPXMock | ||
| from pytest_httpx._options import _HTTPXMockOptions | ||
| from responses import matchers | ||
| from connect.client.fluent import _ConnectClientBase | ||
| @@ -165,7 +166,13 @@ def _get_namespace_class(self): | ||
| _monkeypatch = MonkeyPatch() | ||
| _async_mocker = HTTPXMock() | ||
| # The ConnectClient retries requests, so a single registered response must be | ||
| # able to answer repeated (retried) requests. | ||
| _async_mocker = HTTPXMock( | ||
| _HTTPXMockOptions( | ||
| can_send_already_matched_responses=True, | ||
| ), | ||
| ) | ||
| class AsyncConnectClientMocker(ConnectClientMocker): | ||
| @@ -194,8 +201,14 @@ async def mocked_handle_async_request( | ||
| ) | ||
| def reset(self, success=True): | ||
| _async_mocker.reset(success) | ||
| _monkeypatch.undo() | ||
| try: | ||
| if success: | ||
| # pytest-httpx>=0.31 no longer asserts on reset(); do it explicitly | ||
| # so unrequested mocks / unexpected requests still fail the test. | ||
| _async_mocker._assert_options() | ||
qarlosh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| finally: | ||
| _async_mocker.reset() | ||
| _monkeypatch.undo() | ||
| def mock( | ||
| self, | ||
| @@ -222,7 +235,15 @@ def mock( | ||
| if match_body: | ||
| if isinstance(match_body, (dict, list, tuple)): | ||
| kwargs['match_content'] = json.dumps(match_body).encode('utf-8') | ||
| # Mirror httpx>=0.28's request-body serialization exactly, or | ||
| # match_content won't compare equal (compact separators, raw | ||
| # UTF-8 rather than \uXXXX escapes, and no NaN/Infinity). | ||
| kwargs['match_content'] = json.dumps( | ||
qarlosh marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| match_body, | ||
| separators=(',', ':'), | ||
| ensure_ascii=False, | ||
| allow_nan=False, | ||
| ).encode('utf-8') | ||
| else: | ||
| kwargs['match_content'] = match_body | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.