Registry / testing / looptime

looptime

JSON →
library0.7pypypi✓ verified 30d ago

Utility to fast-forward asyncio event loop time for deterministic testing. Current version 0.7, requires Python >=3.10. Released as a standalone package to replace pytest-asyncio's `loop_context` for controlling virtual time.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from looptime import Chronometer
from looptime import LoopTimeEventLoop
from looptime import new_event_loop

Basic usage: create a Looper, enter it as a context manager, advance time, and exit.

import asyncio from looptime import Looper async def test_sleep(): looper = Looper() asyncio.get_event_loop().run_until_complete(looper.__aenter__()) await asyncio.sleep(3600) # Without looper, this would block for an hour. looper.advance(3600) # Now the sleep completes immediately. await looper.__aexit__(None, None, None)
Debug
Known footguns
gotchaLooper must be used as a context manager (async with). Simply creating a Looper instance without entering will not affect event loop timing.
gotchaAdvancing time via looper.advance() does not automatically wake up tasks; it only moves the clock. Tasks waiting on asyncio.sleep() will only resume when the looper's event loop cycle runs (e.g., after the advance call returns).
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources