The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(responses): inject a mocked http client instead of patching AsyncHTTPHandler.post
mateo-berri39c5ccaed4f6
diff --git a/tests/test_litellm/responses/test_responses_api_request_body.py b/tests/test_litellm/responses/test_responses_api_request_body.pyindex 38dc61c5aa0..ea5eb3afe9a 100644--- a/tests/test_litellm/responses/test_responses_api_request_body.py+++ b/tests/test_litellm/responses/test_responses_api_request_body.py@@ -12,6 +12,7 @@ import httpximport pytestimport litellm+from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandlerdef _expected_dir() -> Path:@@ -384,22 +385,21 @@ async def test_aresponses_strips_responses_routing_prefix_from_openai_model(mode/v1/responses and via the /v1/messages adapter (which passes responses/<model>with custom_llm_provider="openai"), so both shapes must hit OpenAI as <model>."""- with patch(- "litellm.llms.custom_httpx.http_handler.AsyncHTTPHandler.post",- new_callable=AsyncMock,- ) as mock_post:- mock_post.return_value = MockResponse(_minimal_responses_api_payload("resp_prefix_test", "gpt-5.6"), 200)-- await litellm.aresponses(- model=model,- custom_llm_provider=custom_llm_provider,- input="ping",- api_key="sk-test",- )+ injected_client = AsyncHTTPHandler()+ mock_post = AsyncMock(return_value=MockResponse(_minimal_responses_api_payload("resp_prefix_test", "gpt-5.6"), 200))+ injected_client.post = mock_post++ await litellm.aresponses(+ model=model,+ custom_llm_provider=custom_llm_provider,+ input="ping",+ api_key="sk-test",+ client=injected_client,+ )- mock_post.assert_called_once()- assert mock_post.call_args.kwargs["url"].endswith("/responses")- assert mock_post.call_args.kwargs["json"]["model"] == "gpt-5.6"+ mock_post.assert_called_once()+ assert mock_post.call_args.kwargs["url"].endswith("/responses")+ assert mock_post.call_args.kwargs["json"]["model"] == "gpt-5.6"@pytest.mark.asyncio