Skip to content
GitHub

Quickstart

Terminal window
uv add --dev lexigram-testing

For optional extras (web, database, auth, cache, storage, AI):

Terminal window
uv add --dev "lexigram-testing[web,db]"
import pytest
from lexigram.testing import FakeCache
@pytest.mark.asyncio
async 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")
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()
  • FakeCache provided an in-memory cache implementation for fast, deterministic tests
  • TestEnvironment created 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
  • Guide — fakes, compliance suites, test clients, and test environments
  • How-Tos — task-oriented recipes