From 2bc189ff8fa306962818dd5f2ac0d685fcf16798 Mon Sep 17 00:00:00 2001 From: Ambuj Upadhyay Date: Wed, 2 Sep 2026 07:27:01 +0530 Subject: [PATCH] test: narrow the async-streaming regression to openai.OpenAIError Ruff PT011 (test tree) rejects a bare pytest.raises(Exception). Every litellm exception subclasses an openai one, so OpenAIError is the accurate common base here and matches the assertion the first test in this file already uses. The status_code == 400 assertion is unchanged. --- tests/unit/llms/openai/test_openai_sdk_error_status_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/llms/openai/test_openai_sdk_error_status_code.py b/tests/unit/llms/openai/test_openai_sdk_error_status_code.py index c0857fe6e0f..adda6a9f447 100644 --- a/tests/unit/llms/openai/test_openai_sdk_error_status_code.py +++ b/tests/unit/llms/openai/test_openai_sdk_error_status_code.py @@ -64,7 +64,7 @@ async def test_async_streaming_missing_credentials_is_not_a_server_error(monkeyp monkeypatch.setattr(litellm, "api_key", None, raising=False) monkeypatch.setattr(litellm, "openai_key", None, raising=False) - with pytest.raises(Exception) as exc_info: + with pytest.raises(openai.OpenAIError) as exc_info: await litellm.acompletion( model="gpt-4o-mini", messages=[{"role": "user", "content": "hi"}],