Add response_delay_seconds parameter for testing timeouts #2885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds
response_delay_secondsparameter to MockVWS to simulate slow HTTP responses, enabling testing of request timeout handling. When the delay exceeds a client's timeout,requests.exceptions.Timeoutis raised naturally.Test plan
Note
Medium Risk
Adds timing/timeout behavior to the core
MockVWSrequest interception by patching a privateresponseshook and using thread-local timeout capture, which could be brittle across library versions and affect test determinism.Overview
Adds an optional
response_delay_secondsparameter toMockVWSto artificially delay mocked VWS/VWQ responses and surfacerequests.exceptions.Timeoutwhen the delay exceeds the caller’s timeout (including tuple connect/read timeouts).Implements delay by wrapping each
responsescallback and patchingresponses.RequestsMock._on_requestto capture the request’s timeout in thread-local storage; updates tests to cover default no-delay, timeout, success-with-delay, and tuple-timeout behavior, and adjustspyproject.tomlvulture ignores for new TYPE_CHECKING-only names.Written by Cursor Bugbot for commit ddb3f0a. This will update automatically on new commits. Configure here.