@@ -34,3 +34,10 @@ target-version = "py311"
line-length = 100
select = ["E", "F", "I", "N", "W"]
ignore = ["E501"]
+
+[tool.pytest.ini_options]
+# pytest-asyncio 1.x 要求显式 loop scope;B-74 修复(2026-11-09):
+# session 级 autouse async fixture(conftest._init_checkpointer_global)需
+# session/auto 默认 loop scope 方能初始化 checkpointer 并无缝复用于全部测试。
+asyncio_mode = "auto"
+asyncio_default_fixture_loop_scope = "session"
@@ -12,6 +12,18 @@ from httpx import AsyncClient, ASGITransport
from app.main import app
+@pytest.fixture(scope="session", autouse=True)
+async def _init_checkpointer_global():
+ """B-74 修复(2026-11-09):httpx.ASGITransport 直连不触发 FastAPI
+ @app.on_event("startup"),导致 app/checkpointer.py 的 init_checkpointer()
+ 从未执行、全局单例保持 None,凡走 graph 的用例(test_auto_tag×5 /
+ test_chat×1)恒 500。session 级 autouse fixture 在任何用例前显式初始化
+ checkpointer(init_checkpointer 幂等,已初始化则直接返回,不影响生产)。"""
+ from app.checkpointer import init_checkpointer
+ await init_checkpointer()
+ yield
@pytest.fixture
async def client():
transport = ASGITransport(app=app)