Skip to content

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]

test(convert_dict_to_response): expect the type-naming error for a null choices value

mateo-berri21e6c6e2f3c9
diff --git a/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py b/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py
index 09d1adba17c..31c554985a7 100644
--- a/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py
+++ b/tests/llm_translation/test_llm_response_utils/test_convert_dict_to_chat_completion.py
@@ -1645,7 +1645,7 @@ class TestMissingChoicesGuard:
assert result.usage.prompt_tokens == 10
def test_convert_to_model_response_object_null_choices_raises_api_error(self):
- """choices=None raises APIError."""
+ """choices=None raises APIError that names the type instead of claiming the key is missing."""
from litellm.exceptions import APIError
response_object = {
@@ -1661,7 +1661,7 @@ class TestMissingChoicesGuard:
model_response_object=ModelResponse(),
)
- assert "no 'choices'" in exc_info.value.message
+ assert "'choices' that is not a list (NoneType)" in exc_info.value.message
def test_convert_to_streaming_response_no_choices_raises_api_error(self):
"""Missing choices in streaming cache-hit path raises APIError."""