Repository navigation
test(gateway): a stepped trigger clock counts only its own engine's naps - #720
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Three tests in
tst/unit/env/gateway/triggers_test.pyfailed on an unrelated PR (#718, unit (1/2)), each with one extra5.0nap:test_waiting_virtual_time_follows_the_clock_rate[armed-at-60x]:[5.0, 5.0, 5.0, 5.0, 5.0] == [5.0, 5.0, 5.0, 5.0]test_waiting_virtual_time_follows_the_clock_rate[unarmed]:[5.0, 5.0, 2.0, 5.0] == [5.0, 5.0, 2.0]test_waiting_virtual_time_holds_while_frozen_and_follows_a_new_rate:[5.0, 5.0, 5.0, 5.0] == [5.0, 5.0, 5.0, 2.0]The helper they use,
_SteppedClock, patchedasyncio.sleepfor the whole process and counted every call. The unit tier runs on one event loop per worker (asyncio_default_test_loop_scope = "session"), so a sleep from a task another test left running was counted as a step of the wait under test. 5.0 s is the engine's recheck interval,_VIRTUAL_RECHECK_S.What changes
_SteppedClockpatches the engine's own_napinstead. All five tests that use it wait through_sleep_virtual, which sleeps only through_nap, so they step exactly as before, and sleeps from other tests' tasks no longer count. Test-only.Testing
main, one test fails. With this change, all 10 selected tests pass.tst/unit/env/gateway/triggers_test.pypasses six runs in a row with-n 4.🤖 Generated with Claude Code


Confidence Score: 5/5
This test-only change appears safe to merge.Summary
Makes
_SteppedClockreplace one engine’s_napinstead of replacingasyncio.sleepfor the whole process.Reviews (1) · Last reviewed commit: "test(gateway): a stepped trigger clock c..." · Reviewed by Greptile