From c44f62abb50218477c73b72cc2493dc110eb712c Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Tue, 28 Jul 2026 19:08:06 -0700 Subject: [PATCH] test(http_handler): move the GC lifecycle tests to tests/local_testing tests/test_litellm/readme.md states that directory can only contain mocked tests. These need a real connection pool, because a mocked transport goes on yielding chunks after its client is closed, which is the teardown under test. tests/local_testing is the tree for tests that open a real socket, and CircleCI's local_testing_part1 job picks the file up by its name. No change to the tests themselves beyond the sys.path depth and a docstring line naming the new location. --- .../test_handler_gc_does_not_close_client.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename tests/{test_litellm/llms/custom_httpx => local_testing}/test_handler_gc_does_not_close_client.py (96%) diff --git a/tests/test_litellm/llms/custom_httpx/test_handler_gc_does_not_close_client.py b/tests/local_testing/test_handler_gc_does_not_close_client.py similarity index 96% rename from tests/test_litellm/llms/custom_httpx/test_handler_gc_does_not_close_client.py rename to tests/local_testing/test_handler_gc_does_not_close_client.py index 8c95691a9c9..3874405a261 100644 --- a/tests/test_litellm/llms/custom_httpx/test_handler_gc_does_not_close_client.py +++ b/tests/local_testing/test_handler_gc_does_not_close_client.py @@ -18,12 +18,11 @@ Each test below is one shape the finalizers broke; all of them fail if either ``__del__`` comes back. Async cases run on both transports, because litellm defaults to aiohttp and only uses httpcore when aiohttp is disabled. -Unlike the rest of ``tests/test_litellm/``, these tests need a real connection -pool rather than a mock: a mocked transport goes on yielding chunks after its +These live here rather than under ``tests/test_litellm/`` because they need a +real connection pool: a mocked transport goes on yielding chunks after its client is closed, so the very teardown under test is what a mock cannot -reproduce. The server here is the hermetic, credential-free -``ThreadingHTTPServer`` on an ephemeral loopback port already used by -``tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_handler.py``. +reproduce. The server is a hermetic, credential-free ``ThreadingHTTPServer`` +on an ephemeral loopback port, and needs no network access beyond it. Related: https://github.com/BerriAI/litellm/issues/24929 """ @@ -40,7 +39,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer import httpx import pytest -sys.path.insert(0, os.path.abspath("../../../..")) +sys.path.insert(0, os.path.abspath("../..")) import litellm from litellm.caching.llm_caching_handler import LLMClientCache