From 670f8a1dd1802010ae27d1db536f0bd2b62cf625 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sun, 15 Mar 2026 17:10:31 -0700 Subject: [PATCH] Fix flaky test_caching_with_ttl by using distinct mock responses The test asserts that a ttl=0 cached entry expires immediately, so the second call should not return cached content. Both calls used the same mock_response text, making the content != assertion always fail. Use different mock_response values so a cache hit is distinguishable. Co-Authored-By: Claude Opus 4.6 --- tests/local_testing/test_caching.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/local_testing/test_caching.py b/tests/local_testing/test_caching.py index 16564cc690..01004e4bfa 100644 --- a/tests/local_testing/test_caching.py +++ b/tests/local_testing/test_caching.py @@ -200,9 +200,9 @@ def test_caching_with_ttl(): litellm.set_verbose = True litellm.cache = Cache() response1 = completion( - model="gpt-3.5-turbo", messages=messages, caching=True, ttl=0, mock_response="Hello world from cache test" + model="gpt-3.5-turbo", messages=messages, caching=True, ttl=0, mock_response="Hello world from cache test 1" ) - response2 = completion(model="gpt-3.5-turbo", messages=messages, caching=True, mock_response="Hello world from cache test") + response2 = completion(model="gpt-3.5-turbo", messages=messages, caching=True, mock_response="Hello world from cache test 2") print(f"response1: {response1}") print(f"response2: {response2}") litellm.cache = None # disable cache