diff --git a/tests/unit/llms/chatgpt/chat/test_chatgpt_chat_transformation.py b/tests/unit/llms/chatgpt/chat/test_chatgpt_chat_transformation.py index 6222b542d66..78fbea29c6b 100644 --- a/tests/unit/llms/chatgpt/chat/test_chatgpt_chat_transformation.py +++ b/tests/unit/llms/chatgpt/chat/test_chatgpt_chat_transformation.py @@ -441,17 +441,20 @@ async def test_client_login_cannot_be_redirected_to_another_host( **credential, } ) + async def request() -> None: + if endpoint == "chat": + if async_call: + await litellm.acompletion(**params, messages=[{"role": "user", "content": "Hello"}]) + else: + litellm.completion(**params, messages=[{"role": "user", "content": "Hello"}]) + elif async_call: + await litellm.aresponses(**params, input="Hello") + else: + litellm.responses(**params, input="Hello") + with respx.mock as transport: with pytest.raises(litellm.BadRequestError, match="official HTTPS ChatGPT endpoint"): - if endpoint == "chat": - if async_call: - await litellm.acompletion(**params, messages=[{"role": "user", "content": "Hello"}]) - else: - litellm.completion(**params, messages=[{"role": "user", "content": "Hello"}]) - elif async_call: - await litellm.aresponses(**params, input="Hello") - else: - litellm.responses(**params, input="Hello") + await request() assert len(transport.calls) == 0