File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -213,14 +213,20 @@ async def advance_time(self, seconds):
213
213
'''
214
214
if seconds < 0 :
215
215
raise ValueError ('cannot go backwards in time' )
216
- # advance the clock and run the loop
216
+
217
+ # advance the clock by the given offset
217
218
self ._offset += seconds
218
- # Once advanced, new tasks may have just been scheduled for running
219
- # in the next loop, advance once more to start these handlers
220
- await asyncio .sleep (0 )
221
- await asyncio .sleep (0 )
219
+
220
+ # ensure waiting callbacks are run before advancing the clock
222
221
await asyncio .sleep (0 )
223
222
223
+ if seconds > 0 :
224
+ # Once the clock is adjusted, new tasks may have just been scheduled for running
225
+ # in the next pass through the event loop and advance again for the task
226
+ # that calls `advance_time`
227
+ await asyncio .sleep (0 )
228
+ await asyncio .sleep (0 )
229
+
224
230
225
231
# maps marker to the name of the event loop fixture that will be available
226
232
# to marked test functions
You can’t perform that action at this time.
0 commit comments