Quickstart
Install
Section titled “Install”uv add --dev lexigram-testingFor optional extras (web, database, auth, cache, storage, AI):
uv add --dev "lexigram-testing[web,db]"Hello World — FakeCache
Section titled “Hello World — FakeCache”import pytestfrom lexigram.testing import FakeCache
@pytest.mark.asyncioasync def test_cache_roundtrip() -> None: cache = FakeCache()
await cache.set("greeting", "hello", ttl=60) value = await cache.get("greeting")
assert value == "hello" cache.assert_has_key("greeting")Primary Import + TestEnvironment
Section titled “Primary Import + TestEnvironment”from lexigram.testing import TestEnvironment
async def test_with_env() -> None: env = TestEnvironment() await env.setup()
# Fakes are pre-wired into the container service = MyService(event_bus=env.event_bus) await service.do_something()
env.teardown()What Just Happened
Section titled “What Just Happened”FakeCacheprovided an in-memory cache implementation for fast, deterministic testsTestEnvironmentcreated a pre-wired DI container with in-memory fakes for event bus, command bus, query bus, audit logger, and distributed lock- No infrastructure setup required — no Redis, no database, no external services