From d7b0a8c559db5ff238eeb5159a59f7b10e8c9f2f Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Tue, 17 Feb 2026 21:18:49 -0300 Subject: [PATCH] fix(tests): restore disable_aiohttp_transport and force_ipv4 in isolate_litellm_state Many tests across the llms group (sap, compactifai, vercel_ai_gateway, mistral, zai, heroku) set litellm.disable_aiohttp_transport = True without restoring it. When these tests run before test_ssl_context_transport or test_session_reuse_chain in the same xdist worker, _create_async_transport() returns None (because aiohttp is disabled AND force_ipv4 is False), causing both tests to fail with 'assert None is not None'. Fix: extend isolate_litellm_state in conftest.py to also save and restore disable_aiohttp_transport and force_ipv4, following the same pattern already used for callbacks. Co-Authored-By: Claude Sonnet 4.6 --- tests/test_litellm/conftest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_litellm/conftest.py b/tests/test_litellm/conftest.py index 1106af1a39..34cdac15ba 100644 --- a/tests/test_litellm/conftest.py +++ b/tests/test_litellm/conftest.py @@ -49,6 +49,12 @@ def isolate_litellm_state(): if hasattr(litellm, '_async_failure_callback'): original_state['_async_failure_callback'] = litellm._async_failure_callback.copy() if litellm._async_failure_callback else [] + # Store transport/network globals — many tests set these without restoring, + # causing subsequent tests to get None from _create_async_transport() + for _attr in ('disable_aiohttp_transport', 'force_ipv4'): + if hasattr(litellm, _attr): + original_state[_attr] = getattr(litellm, _attr) + # Flush cache before test (critical for respx mocks) if hasattr(litellm, "in_memory_llm_clients_cache"): litellm.in_memory_llm_clients_cache.flush_cache()