From bd8df0ed8f8f1ebb0e5529148578a85b030c9393 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 21 Sep 2026 12:54:23 -0700 Subject: [PATCH] test: keep the Qwen brand missing-key tests off the network and split the ChatGPT fields test back out --- .../llms/dashscope/test_qwen_brand_aliases.py | 16 +++++++++++++--- .../public_endpoints/test_public_endpoints.py | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py b/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py index 6f264ea1424..69ae66d3818 100644 --- a/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py +++ b/tests/test_litellm/llms/dashscope/test_qwen_brand_aliases.py @@ -95,6 +95,13 @@ BRAND_CASES = [ def clear_dashscope_family_env(monkeypatch): for env_var in DASHSCOPE_FAMILY_ENV_VARS: monkeypatch.delenv(env_var, raising=False) + monkeypatch.setattr(litellm, "api_key", None) + + +@pytest.fixture +def no_provider_traffic(respx_mock, monkeypatch): + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + return respx_mock class TestQwenBrandProviderResolution: @@ -267,22 +274,25 @@ class TestQwenBrandUserFacingNames: assert self.RETIRED_MAINLAND_NAME not in message @pytest.mark.parametrize("brand", BRAND_CASES) - def test_embedding_without_key_names_brand(self, brand): + def test_embedding_without_key_names_brand(self, brand, no_provider_traffic): with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info: litellm.embedding(model=f"{brand['provider']}/text-embedding-v4", input=["hello"]) assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value) + assert no_provider_traffic.calls.call_count == 0 @pytest.mark.parametrize("brand", BRAND_CASES) - def test_rerank_without_key_names_brand(self, brand): + def test_rerank_without_key_names_brand(self, brand, no_provider_traffic): with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info: litellm.rerank(model=f"{brand['provider']}/gte-rerank-v2", query="q", documents=["a", "b"]) assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value) + assert no_provider_traffic.calls.call_count == 0 @pytest.mark.parametrize("brand", BRAND_CASES) - def test_image_generation_without_key_names_brand(self, brand): + def test_image_generation_without_key_names_brand(self, brand, no_provider_traffic): with pytest.raises(litellm.APIConnectionError, match=re.escape(brand["display_name"])) as exc_info: litellm.image_generation(model=f"{brand['provider']}/qwen-image", prompt="a cup of coffee") assert self.RETIRED_MAINLAND_NAME not in str(exc_info.value) + assert no_provider_traffic.calls.call_count == 0 @pytest.mark.parametrize("brand", BRAND_CASES) @pytest.mark.parametrize( diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py index ba88fbd3951..0f1ff3b024d 100644 --- a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py +++ b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py @@ -357,6 +357,9 @@ def test_qwen_mainland_provider_fields_carry_the_qianwen_brand(): assert mainland_fields["api_key"]["label"] == "Qianwen AI Platform API Key" assert "Qianwen AI Platform" in mainland_fields["api_base"]["tooltip"] assert "Qwen AI Platform" not in json.dumps(mainland) + + +def test_chatgpt_provider_fields(): app_instance = FastAPI() app_instance.include_router(router) test_client = TestClient(app_instance)