conftest.py 650 B

12345678910111213141516171819202122232425
  1. # 兼容旧版系统 sqlite3 (<3.35):chromadb 需要更高版本。
  2. # 仅测试环境生效(conftest 不参与生产加载);若系统已装新版 sqlite3 可移除。
  3. try:
  4. import pysqlite3
  5. import sys
  6. sys.modules["sqlite3"] = pysqlite3
  7. except ImportError:
  8. pass
  9. import pytest
  10. from httpx import AsyncClient, ASGITransport
  11. from app.main import app
  12. @pytest.fixture
  13. async def client():
  14. transport = ASGITransport(app=app)
  15. async with AsyncClient(transport=transport, base_url="http://test") as ac:
  16. yield ac
  17. @pytest.fixture
  18. async def health_response(client):
  19. resp = await client.get("/health")
  20. return resp