From 392fa61ac3f8be3b5656f78b1960d1dd76049f6a Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Sun, 15 Feb 2026 14:18:00 -0300 Subject: [PATCH] fix(test): flush client cache before test_extra_body_with_fallback Add client cache flush before setting disable_aiohttp_transport to prevent cache pollution. Previous tests may cache HTTP clients with aiohttp enabled, which bypass respx mocks and cause real API calls to fail. This follows the same pattern as test_openai_env_base which also uses respx. Related to #8425 Co-Authored-By: Claude Sonnet 4.5 --- tests/test_litellm/test_main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_litellm/test_main.py b/tests/test_litellm/test_main.py index fec7fdaee94..998ff19aac6 100644 --- a/tests/test_litellm/test_main.py +++ b/tests/test_litellm/test_main.py @@ -427,6 +427,12 @@ async def test_extra_body_with_fallback( original_disable_aiohttp = litellm.disable_aiohttp_transport try: + # Clear cache to ensure no cached clients from previous tests interfere + # This prevents cache pollution where a previous test cached a client with + # aiohttp transport, which would bypass respx mocks + if hasattr(litellm, "in_memory_llm_clients_cache"): + litellm.in_memory_llm_clients_cache.flush_cache() + # since this uses respx, we need to set use_aiohttp_transport to False litellm.disable_aiohttp_transport = True # Set up test parameters