from fastapi import Depends # app dependency definition (in app code) def get_runtime(): return app.state.runtime @app.get("/agents") async def list_agents(runtime = Depends(get_runtime)): return await runtime.list_agents() # test override @pytest.fixture def client_override_dep(): fake_runtime = Mock() fake_runtime.list_agents = AsyncMock(return_value=[{"id": "a1"}]) from dotigent.backend.app.main import app, get_runtime app.dependency_overrides[get_runtime] = lambda: fake_runtime try: with TestClient(app) as client: yield client finally: app.dependency_overrides.clear()