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
fix(tests): use monkeypatch.setenv for Redis pool max_connections tests (#21834)
Ishaan Jaff59e5b7e8c687
diff --git a/tests/test_litellm/caching/test_redis_connection_pool.py b/tests/test_litellm/caching/test_redis_connection_pool.pyindex 69381653ac0..b8922846e82 100644--- a/tests/test_litellm/caching/test_redis_connection_pool.py+++ b/tests/test_litellm/caching/test_redis_connection_pool.py@@ -39,29 +39,25 @@ def test_url_config_falls_back_to_from_url_without_pool():assert client.connection_pool is not None-def test_max_connections_url_config():+def test_max_connections_url_config(monkeypatch):"""max_connections should be respected when using URL-based config."""- with patch("litellm._redis._get_redis_client_logic") as mock_logic:- mock_logic.return_value = {- "url": "redis://localhost:6379/0",- "max_connections": 10,- }+ monkeypatch.setenv("REDIS_URL", "redis://localhost:6379/0")+ monkeypatch.delenv("REDIS_HOST", raising=False)+ monkeypatch.setenv("REDIS_MAX_CONNECTIONS", "10")- pool = get_redis_connection_pool()+ pool = get_redis_connection_pool()assert pool.max_connections == 10-def test_max_connections_url_config_string_value():+def test_max_connections_url_config_string_value(monkeypatch):"""max_connections provided as a string (from env var) should becast to int."""- with patch("litellm._redis._get_redis_client_logic") as mock_logic:- mock_logic.return_value = {- "url": "redis://localhost:6379/0",- "max_connections": "25",- }+ monkeypatch.setenv("REDIS_URL", "redis://localhost:6379/0")+ monkeypatch.delenv("REDIS_HOST", raising=False)+ monkeypatch.setenv("REDIS_MAX_CONNECTIONS", "25")- pool = get_redis_connection_pool()+ pool = get_redis_connection_pool()assert pool.max_connections == 25