The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Refactor: Skip PublicAI tests if API key is not set (#17540)
Krish Dholakia85d73403f4a5
diff --git a/tests/test_litellm/llms/openai_like/test_json_providers.py b/tests/test_litellm/llms/openai_like/test_json_providers.pyindex e17cb714331..5efd3c4cd6d 100644--- a/tests/test_litellm/llms/openai_like/test_json_providers.py+++ b/tests/test_litellm/llms/openai_like/test_json_providers.py@@ -132,10 +132,11 @@ class TestPublicAIIntegration:def test_publicai_completion_basic(self):"""Test basic completion call to PublicAI"""- # Set API key from the one provided- os.environ["PUBLICAI_API_KEY"] = (- "zpka_9ea399e9e81b4ece8af0fe88d2561c4f_4e4e9dec"- )+ # Skip test if API key not set in environment+ if not os.environ.get("PUBLICAI_API_KEY"):+ if pytest:+ pytest.skip("PUBLICAI_API_KEY not set")+ returntry:response = litellm.completion(@@ -166,9 +167,11 @@ class TestPublicAIIntegration:def test_publicai_completion_with_streaming(self):"""Test streaming completion with PublicAI"""- os.environ["PUBLICAI_API_KEY"] = (- "zpka_9ea399e9e81b4ece8af0fe88d2561c4f_4e4e9dec"- )+ # Skip test if API key not set in environment+ if not os.environ.get("PUBLICAI_API_KEY"):+ if pytest:+ pytest.skip("PUBLICAI_API_KEY not set")+ returntry:response = litellm.completion(@@ -203,9 +206,11 @@ class TestPublicAIIntegration:def test_publicai_parameter_mapping(self):"""Test that max_completion_tokens is mapped to max_tokens"""- os.environ["PUBLICAI_API_KEY"] = (- "zpka_9ea399e9e81b4ece8af0fe88d2561c4f_4e4e9dec"- )+ # Skip test if API key not set in environment+ if not os.environ.get("PUBLICAI_API_KEY"):+ if pytest:+ pytest.skip("PUBLICAI_API_KEY not set")+ returntry:# Use max_completion_tokens (OpenAI's newer parameter)@@ -228,9 +233,11 @@ class TestPublicAIIntegration:def test_publicai_content_list_conversion(self):"""Test that content list format is converted to string"""- os.environ["PUBLICAI_API_KEY"] = (- "zpka_9ea399e9e81b4ece8af0fe88d2561c4f_4e4e9dec"- )+ # Skip test if API key not set in environment+ if not os.environ.get("PUBLICAI_API_KEY"):+ if pytest:+ pytest.skip("PUBLICAI_API_KEY not set")+ returntry:# Send message with content as list (should be converted to string)