Skip to content

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]

test(proxy): clear failed-login TTLs when resetting the throttle between tests

Yucheng Zhua39efb1a1d59
diff --git a/tests/test_litellm/proxy/proxy_server/conftest.py b/tests/test_litellm/proxy/proxy_server/conftest.py
index cdfd3549544..22f2e5b3feb 100644
--- a/tests/test_litellm/proxy/proxy_server/conftest.py
+++ b/tests/test_litellm/proxy/proxy_server/conftest.py
@@ -527,10 +527,17 @@ def reset_login_throttle(monkeypatch):
def _drop_throttle_keys() -> None:
in_memory = getattr(_FAILED_LOGIN_CACHE, "in_memory_cache", None)
- cache_dict = getattr(in_memory, "cache_dict", None)
- if isinstance(cache_dict, dict):
- for key in [k for k in cache_dict if str(k).startswith(_CACHE_KEY_PREFIX)]:
- cache_dict.pop(key, None)
+ if in_memory is None:
+ return
+ tracked = tuple(
+ key
+ for store in (getattr(in_memory, "cache_dict", None), getattr(in_memory, "ttl_dict", None))
+ if isinstance(store, dict)
+ for key in tuple(store)
+ if str(key).startswith(_CACHE_KEY_PREFIX)
+ )
+ for key in tracked:
+ in_memory.delete_cache(key)
monkeypatch.setattr(ps, "redis_usage_cache", None)
_drop_throttle_keys()