Skip to content

Commit 1d3cd51

Browse files
committed
rework advance_time to reduce complexity
1 parent 559e883 commit 1d3cd51

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pytest_asyncio/plugin.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,12 @@ def advance_time(self, seconds):
235235
that will complete after all tasks scheduled for after advancement
236236
of time are proceeding.
237237
'''
238-
if seconds <= 0:
239-
# cannot go backwards in time, so return after one iteration of a loop
240-
return self.create_task(asyncio.sleep(0))
241-
242-
# advance the clock by the given offset
243-
self._offset += seconds
238+
if seconds > 0:
239+
# advance the clock by the given offset
240+
self._offset += seconds
244241

245242
# Once the clock is adjusted, new tasks may have just been
246-
# scheduled for running in the next pass through the event loop and
247-
# advance again for the newly ready tasks
243+
# scheduled for running in the next pass through the event loop
248244
return self.create_task(asyncio.sleep(0))
249245

250246
return ClockEventLoop

0 commit comments

Comments
 (0)