asynciotimemachine module

Main module.

class asynciotimemachine.TimeMachine(*poargs, event_loop: Optional[asyncio.events.AbstractEventLoop] = None, **kwargs)[source]

Bases: object

A monkey-patch helper to advance an event loop’s time.

Parameters:event_loop – the event loop to monkey-patch (default: main loop).
advance_by(amount: float)[source]

Advance the time reference by the given amount.

Parameters:amount – number of seconds to advance.
Raises:ValueError – if amount is negative.
advance_to(timestamp: float)[source]

Advance the time reference so that now is the given timestamp.

Parameters:timestamp – the new current timestamp.
Raises:ValueError – if timestamp is in the past.