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: remove five more zero-kill tests from test_http_handler
Yuneng Jiang9f9714c209b3
diff --git a/tests/test_litellm/llms/custom_httpx/test_http_handler.py b/tests/test_litellm/llms/custom_httpx/test_http_handler.pyindex 7bd1d7a6031..87d67e0e8b7 100644--- a/tests/test_litellm/llms/custom_httpx/test_http_handler.py+++ b/tests/test_litellm/llms/custom_httpx/test_http_handler.py@@ -181,28 +181,6 @@ async def test_force_ipv4_transport():litellm.disable_aiohttp_transport = original_disable-async def test_ssl_context_transport():- """Test transport creation with SSL context"""- # Create a test SSL context- ssl_context = ssl.create_default_context()-- transport = AsyncHTTPHandler._create_async_transport(ssl_context=ssl_context)- assert transport is not None-- try:- if isinstance(transport, LiteLLMAiohttpTransport):- # Get the client session and verify SSL context is passed through- client_session = transport._get_valid_client_session()- assert isinstance(client_session, ClientSession)- assert isinstance(client_session.connector, TCPConnector)- # Verify the connector has SSL context set by checking if it's using SSL- assert client_session.connector._ssl is not None- finally:- if isinstance(transport, LiteLLMAiohttpTransport):- await transport.aclose()--@pytest.mark.asyncioasync def test_aiohttp_disabled_transport():"""Test transport creation with aiohttp disabled"""@@ -339,44 +317,6 @@ async def test_ssl_context_with_shared_session():litellm.disable_aiohttp_transport = original_disable-async def test_aiohttp_transport_trust_env_setting(monkeypatch):- """Test that trust_env setting is properly configured in aiohttp transport"""- transports = []- try:- # Test 1: Default trust_env behavior- transport = AsyncHTTPHandler._create_aiohttp_transport()- transports.append(transport)- client_session = transport._get_valid_client_session()-- # Default should be False (litellm.aiohttp_trust_env default)- default_trust_env = getattr(litellm, "aiohttp_trust_env", False)- assert client_session._trust_env == default_trust_env-- # Test 2: Environment variable override- monkeypatch.setenv("AIOHTTP_TRUST_ENV", "True")- transport_with_env = AsyncHTTPHandler._create_aiohttp_transport()- transports.append(transport_with_env)- client_session_with_env = transport_with_env._get_valid_client_session()-- # Should be True when environment variable is set- assert client_session_with_env._trust_env is True-- # Test 3: Verify environment variable with False value- monkeypatch.setenv("AIOHTTP_TRUST_ENV", "False")- transport_with_false_env = AsyncHTTPHandler._create_aiohttp_transport()- transports.append(transport_with_false_env)- client_session_with_false_env = (- transport_with_false_env._get_valid_client_session()- )-- # Should respect the litellm.aiohttp_trust_env setting when env var is False- assert client_session_with_false_env._trust_env == default_trust_env- finally:- for t in transports:- await t.aclose()--def test_get_ssl_configuration():"""Test that get_ssl_configuration() returns a proper SSL context with certifi CA bundlewhen no environment variables are set."""@@ -443,36 +383,6 @@ async def test_create_aiohttp_transport_with_shared_session():assert not callable(transport.client) # Should not be callable-async def test_create_aiohttp_transport_without_shared_session():- """Test that _create_aiohttp_transport creates new session when none provided"""- from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler-- # Test without shared session- transport = AsyncHTTPHandler._create_aiohttp_transport(shared_session=None)-- # Verify the transport uses a lambda function (for backward compatibility)- assert callable(transport.client) # Should be a lambda function---async def test_create_aiohttp_transport_with_closed_session():- """Test that _create_aiohttp_transport creates new session when shared session is closed"""- from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler-- # Create a mock closed session- mock_session = MockClientSession()- mock_session.closed = True-- # Test with closed session- transport = AsyncHTTPHandler._create_aiohttp_transport(- shared_session=mock_session # type: ignore- )-- # Verify the transport creates a new session (lambda function)- assert callable(transport.client) # Should be a lambda function--@pytest.mark.asyncioasync def test_async_handler_with_shared_session():"""Test AsyncHTTPHandler initialization with shared session"""@@ -622,27 +532,6 @@ async def test_session_reuse_integration():await client2.close()-async def test_session_validation():- """Test that session validation works correctly"""- from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler-- # Test with None session- transport1 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=None)- assert callable(transport1.client) # Should create lambda-- # Test with closed session- mock_closed_session = MockClientSession()- mock_closed_session.closed = True- transport2 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=mock_closed_session) # type: ignore- assert callable(transport2.client) # Should create lambda-- # Test with valid session- mock_valid_session = MockClientSession()- transport3 = AsyncHTTPHandler._create_aiohttp_transport(shared_session=mock_valid_session) # type: ignore- assert transport3.client is mock_valid_session # Should reuse session--@pytest.mark.parametrize("env_curve,litellm_curve,expected_curve,should_call",[