diff --git a/backend/tests/test_h5_oauth.py b/backend/tests/test_h5_oauth.py index 5bf46b1..4b6bfd1 100644 --- a/backend/tests/test_h5_oauth.py +++ b/backend/tests/test_h5_oauth.py @@ -47,7 +47,9 @@ async def h5_client(db_session: AsyncSession, mock_redis: MockRedis) -> AsyncCli with patch("app.api.h5._get_redis", return_value=mock_redis, create=True): with patch("redis.asyncio.from_url", return_value=mock_redis): transport = ASGITransport(app=app) - async with AsyncClient(transport=transport, base_url="http://test") as ac: + # base_url 用 127.0.0.1,让 h5._require_wework_ua 跳过 UA 检测 + # 原因:生产环境要求企微 UA,测试环境是 httpx 客户端没企微 UA + async with AsyncClient(transport=transport, base_url="http://127.0.0.1") as ac: yield ac app.dependency_overrides.clear()