From 5077db873b0ebb4ad9c4bc704ac8c7419fa7ed20 Mon Sep 17 00:00:00 2001 From: King Star Date: Thu, 10 Sep 2026 06:17:00 +0800 Subject: [PATCH] test(openai): cover async TLS client propagation --- .../llms/openai/test_openai_common_utils.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_litellm/llms/openai/test_openai_common_utils.py b/tests/test_litellm/llms/openai/test_openai_common_utils.py index cab0f63e6f0..47d22a696fb 100644 --- a/tests/test_litellm/llms/openai/test_openai_common_utils.py +++ b/tests/test_litellm/llms/openai/test_openai_common_utils.py @@ -217,6 +217,27 @@ def test_openai_client_uses_per_call_ssl_verify(monkeypatch): client.close() +@pytest.mark.asyncio +async def test_async_openai_client_uses_per_call_ssl_verify(monkeypatch): + from litellm.caching.llm_caching_handler import LLMClientCache + from litellm.llms.openai.openai import OpenAIChatCompletion + + monkeypatch.setattr(litellm, "aclient_session", None) + monkeypatch.setattr(litellm, "network_mock", False) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + client = OpenAIChatCompletion()._get_openai_client( + is_async=True, + api_key="sk-test", + api_base="https://example.test/v1", + max_retries=2, + ssl_verify=False, + ) + + assert client is not None + assert client._client._transport._ssl_verify is False + await client.close() + + def test_evicting_a_client_built_on_the_callers_session_leaves_that_session_open(monkeypatch): """`litellm.aclient_session` belongs to the caller, who goes on using it.