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 <noreply@anthropic.com>
This commit is contained in:
Julio Quinteros Pro 2026-02-15 14:18:00 -03:00
parent 4f751bf815
commit 392fa61ac3

View file

@ -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