From dce597b806ea029d8a15390c2dde09fa83a463da Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Fri, 27 Feb 2026 12:58:33 -0800 Subject: [PATCH] Close httpx clients after assertions to prevent resource leaks --- tests/test_litellm/caching/test_llm_client_cache_e2e.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/caching/test_llm_client_cache_e2e.py b/tests/test_litellm/caching/test_llm_client_cache_e2e.py index b1f8be3b48..a7d012d226 100644 --- a/tests/test_litellm/caching/test_llm_client_cache_e2e.py +++ b/tests/test_litellm/caching/test_llm_client_cache_e2e.py @@ -23,9 +23,11 @@ async def test_evicted_client_is_not_closed(): one, then verify the first client's transport is still open.""" client_a = get_async_httpx_client(llm_provider="provider_a") # This evicts client_a from cache (capacity=1) - get_async_httpx_client(llm_provider="provider_b") + client_b = get_async_httpx_client(llm_provider="provider_b") assert not client_a.client.is_closed + await client_a.client.aclose() + await client_b.client.aclose() @pytest.mark.asyncio @@ -42,3 +44,4 @@ async def test_expired_client_is_not_closed(): cache.evict_cache() assert not client.client.is_closed + await client.client.aclose()