Skip to content

Add injectable sleep_fn parameter to MockVWS#2920

Merged
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/rm-changelog-gaps
Feb 15, 2026
Merged

Add injectable sleep_fn parameter to MockVWS#2920
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/rm-changelog-gaps

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Feb 15, 2026

Summary

Implements issue #2919 by adding an injectable sleep_fn parameter to MockVWS. This allows callers to inject a custom delay strategy for testing timeout behavior without monkeypatching internals.

Changes

  • Add sleep_fn: Callable[[float], None] = time.sleep parameter to MockVWS.__init__
  • Pass the sleep function through _wrap_callback for both the timeout and success code paths
  • Add two comprehensive tests verifying the injected function is called correctly on both paths
  • Update CHANGELOG with feature description

Test plan

✓ All 6 existing and new response delay tests pass
✓ Custom sleep function is called with correct delay value on success path
✓ Custom sleep function is called with effective timeout on timeout path

🤖 Generated with Claude Code


Note

Low Risk
Small, additive API change limited to test/mock timing behavior; primary risk is minor backward-compatibility/typing issues for callers constructing MockVWS.

Overview
MockVWS now accepts an injectable sleep_fn (defaulting to time.sleep) and threads it through the response-delay wrapper so both the timeout and successful delay paths use the provided sleep strategy instead of hardcoded sleeping.

Adds tests asserting the injected function is called with the configured delay or the effective timeout value, and documents the new parameter in CHANGELOG.rst.

Written by Cursor Bugbot for commit b3c1cc3. This will update automatically on new commits. Configure here.

Enable deterministic test-time delay handling by allowing callers to inject a custom sleep strategy. This avoids the need for monkeypatching and enables virtual time control with libraries like freezegun.

- Add sleep_fn parameter to MockVWS.__init__ with default time.sleep
- Pass sleep_fn through to _wrap_callback for both timeout and delay paths
- Add tests verifying injected sleep_fn is called on both success and timeout paths
- Update changelog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamtheturtle adamtheturtle force-pushed the adamtheturtle/rm-changelog-gaps branch from 06066d9 to b3c1cc3 Compare February 15, 2026 11:45
@adamtheturtle adamtheturtle merged commit c8871ba into main Feb 15, 2026
15 checks passed
@adamtheturtle adamtheturtle deleted the adamtheturtle/rm-changelog-gaps branch February 15, 2026 11:50
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

Comments