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: keep a real assertion where the tolerance handler lost its last one
ryan-crabbe-berri6266b3d50a1b
diff --git a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.pyindex 439cdbdc777..a53efdd8255 100644--- a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py+++ b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py@@ -136,6 +136,7 @@ async def test_anthropic_messages_streaming_with_bad_request():"""Test the anthropic_messages with streaming request"""+ error = Nonetry:response = await litellm.anthropic.messages.acreate(messages=[{"role": "user", "content": "hi"}],@@ -149,10 +150,10 @@ async def test_anthropic_messages_streaming_with_bad_request():async for chunk in response:print("chunk=", chunk)except Exception as e:- print("got exception", e)- print("vars", vars(e))- if getattr(e, "status_code", 400) != 400:- raise+ error = e++ if error is not None:+ assert getattr(error, "status_code", 400) == 400, f"got {vars(error)}"@pytest.mark.asyncio@@ -160,6 +161,7 @@ async def test_anthropic_messages_router_streaming_with_bad_request():"""Test the anthropic_messages with streaming request"""+ error = Nonetry:router = Router(model_list=[@@ -184,10 +186,10 @@ async def test_anthropic_messages_router_streaming_with_bad_request():async for chunk in response:print("chunk=", chunk)except Exception as e:- print("got exception", e)- print("vars", vars(e))- if getattr(e, "status_code", 400) != 400:- raise+ error = e++ if error is not None:+ assert getattr(error, "status_code", 400) == 400, f"got {vars(error)}"@pytest.mark.asynciodiff --git a/tests/proxy_unit_tests/test_proxy_server.py b/tests/proxy_unit_tests/test_proxy_server.pyindex 150b90fc8c4..bb8127a8b91 100644--- a/tests/proxy_unit_tests/test_proxy_server.py+++ b/tests/proxy_unit_tests/test_proxy_server.py@@ -1466,17 +1466,19 @@ async def test_create_team_member_add_team_admin(MagicMock(return_value=tx_cm),),):+ error = Nonetry:await team_member_add(data=team_member_add_request,user_api_key_dict=valid_token,)except HTTPException as e:- if (- user_role == "user" or new_member_method == "user_id"- ) and e.status_code == 403:- return- raise+ error = e++ if error is not None:+ assert user_role == "user" or new_member_method == "user_id"+ assert error.status_code == 403+ returnmock_client.assert_called()diff --git a/tests/test_litellm/google_genai/test_google_genai_adapter_fixes.py b/tests/test_litellm/google_genai/test_google_genai_adapter_fixes.pyindex d51452aec1b..36022dcb5db 100644--- a/tests/test_litellm/google_genai/test_google_genai_adapter_fixes.py+++ b/tests/test_litellm/google_genai/test_google_genai_adapter_fixes.py@@ -219,14 +219,13 @@ def test_stream_transformation_error_handling():# Create a wrappermock_wrapper = GoogleGenAIStreamWrapper(completion_stream=iter([]))- # Try to transform - this should either succeed or raise a ValueError, never crash- try:+ # An empty `choices` leaves nothing to emit, so the adapter drops the chunk+ assert (adapter.translate_streaming_completion_to_generate_content(mock_response, mock_wrapper)- except ValueError:- # We won't check the exact message as it might vary- pass+ is None+ )def test_non_stream_response_when_stream_requested():diff --git a/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank.py b/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank.pyindex 4633cd5c6b0..a1e47f815e7 100644--- a/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank.py+++ b/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank.py@@ -303,14 +303,10 @@ def test_deepinfra_rerank_models():]for model in models:- # This should not raise any validation errors- try:- litellm.get_llm_provider(model=model)- except Exception as e:- # We expect this to potentially fail due to missing api_base/key- # but the model format should be recognized- if "api_base" not in str(e) and "API key" not in str(e):- raise+ resolved_model, provider, _, api_base = litellm.get_llm_provider(model=model)+ assert provider == "deepinfra"+ assert resolved_model == model.removeprefix("deepinfra/")+ assert api_base == "https://api.deepinfra.com/v1/openai"@patch("litellm.llms.custom_httpx.http_handler.HTTPHandler.post")diff --git a/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank_integration.py b/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank_integration.pyindex e61ba81cf09..5b013681864 100644--- a/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank_integration.py+++ b/tests/test_litellm/llms/deepinfra/test_deepinfra_rerank_integration.py@@ -317,7 +317,7 @@ def test_deepinfra_rerank_defaults_api_base_when_missing(mock_post, monkeypatch)mock_response.headers = {"content-type": "application/json"}mock_post.return_value = mock_response- litellm.rerank(+ response = litellm.rerank(model="deepinfra/Qwen/Qwen3-Reranker-0.6B",query="hello",documents=["hello", "world"],@@ -327,6 +327,7 @@ def test_deepinfra_rerank_defaults_api_base_when_missing(mock_post, monkeypatch))assert "api.deepinfra.com" in mock_post.call_args.kwargs["url"]+ assert [result["relevance_score"] for result in response.results] == [0.9, 0.1]@patch("litellm.llms.custom_httpx.http_handler.HTTPHandler.post")@@ -390,14 +391,10 @@ def test_deepinfra_rerank_models():]for model in models:- # This should not raise any validation errors- try:- litellm.get_llm_provider(model=model)- except Exception as e:- # We expect this to potentially fail due to missing api_base/key- # but the model format should be recognized- if "api_base" not in str(e) and "API key" not in str(e):- raise+ resolved_model, provider, _, api_base = litellm.get_llm_provider(model=model)+ assert provider == "deepinfra"+ assert resolved_model == model.removeprefix("deepinfra/")+ assert api_base == "https://api.deepinfra.com/v1/openai"@patch("litellm.llms.custom_httpx.http_handler.HTTPHandler.post")