From d1b9611c97678ba091203b23f4cd276be358099f Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 18 Sep 2025 10:13:32 -0700 Subject: [PATCH] fix: test_completion_with_no_model --- tests/litellm_utils_tests/test_utils.py | 13 +++ tests/local_testing/test_bad_params.py | 106 ------------------------ 2 files changed, 13 insertions(+), 106 deletions(-) delete mode 100644 tests/local_testing/test_bad_params.py diff --git a/tests/litellm_utils_tests/test_utils.py b/tests/litellm_utils_tests/test_utils.py index 8d4fc3ac451..5405b7fc792 100644 --- a/tests/litellm_utils_tests/test_utils.py +++ b/tests/litellm_utils_tests/test_utils.py @@ -2326,3 +2326,16 @@ def test_get_whitelisted_models(): file.write(f"{model}\n") print("whitelisted_models written to whitelisted_bedrock_models.txt") + + + +def test_completion_with_no_model(): + """ + Ensure error is raised when no model is provided + """ + # test on empty + with pytest.raises(TypeError): + response = litellm.completion(messages=[{"role": "user", "content": "Hello, how are you?"}]) + + + assert "model is not set. Set either via 'model' or 'engine' param." in str(e) \ No newline at end of file diff --git a/tests/local_testing/test_bad_params.py b/tests/local_testing/test_bad_params.py deleted file mode 100644 index 221135df901..00000000000 --- a/tests/local_testing/test_bad_params.py +++ /dev/null @@ -1,106 +0,0 @@ -#### What this tests #### -# This tests chaos monkeys - if random parts of the system are broken / things aren't sent correctly - what happens. -# Expect to add more edge cases to this over time. - -import os -import sys -import traceback - -import pytest - -sys.path.insert( - 0, os.path.abspath("../..") -) # Adds the parent directory to the system path -import litellm -from litellm import completion, embedding -from litellm.utils import Message - -# litellm.set_verbose = True -user_message = "Hello, how are you?" -messages = [{"content": user_message, "role": "user"}] -model_val = None - - -def test_completion_with_no_model(): - # test on empty - with pytest.raises(TypeError): - response = completion(messages=messages) - - -def test_completion_with_empty_model(): - # test on empty - try: - response = completion(model=model_val, messages=messages) - except Exception as e: - print(f"error occurred: {e}") - pass - - -def test_completion_invalid_param_cohere(): - try: - litellm.set_verbose = True - response = completion(model="command-nightly", messages=messages, seed=12) - pytest.fail(f"This should have failed cohere does not support `seed` parameter") - except Exception as e: - assert isinstance(e, litellm.UnsupportedParamsError) - print("got an exception=", str(e)) - if "cohere does not support parameters: ['seed']" in str(e): - pass - else: - pytest.fail(f"An error occurred {e}") - - -def test_completion_function_call_cohere(): - try: - response = completion( - model="command-nightly", messages=messages, functions=["TEST-FUNCTION"] - ) - pytest.fail(f"An error occurred {e}") - except Exception as e: - print(e) - pass - - -def test_completion_function_call_openai(): - try: - messages = [{"role": "user", "content": "What is the weather like in Boston?"}] - response = completion( - model="gpt-3.5-turbo", - messages=messages, - functions=[ - { - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "The city and state, e.g. San Francisco, CA", - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"], - }, - }, - "required": ["location"], - }, - } - ], - ) - print(f"response: {response}") - except Exception: - pass - - -# test_completion_function_call_openai() - - -def test_completion_with_no_provider(): - # test on empty - try: - model = "cerebras/btlm-3b-8k-base" - response = completion(model=model, messages=messages) - except Exception as e: - print(f"error occurred: {e}") - pass