From a6ca96710582b40da539653222a77f01481ee2e9 Mon Sep 17 00:00:00 2001 From: Dev Chiniwala Date: Mon, 26 Oct 2026 17:49:29 +0530 Subject: [PATCH] test(responses): keep exception assertions to one call --- .../litellm_completion_transformation/test_handler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/responses/litellm_completion_transformation/test_handler.py b/tests/unit/responses/litellm_completion_transformation/test_handler.py index 9ffd4939903..53a0cd68ea1 100644 --- a/tests/unit/responses/litellm_completion_transformation/test_handler.py +++ b/tests/unit/responses/litellm_completion_transformation/test_handler.py @@ -279,8 +279,8 @@ async def test_unknown_previous_response_fails_before_sending_a_contextless_comp async_client: Final = AsyncHTTPHandler(transport=transport) with httpx.Client(transport=transport) as sync_client: try: - with pytest.raises(litellm.BadRequestError, match="previous_response_id") as raised: - if async_call: + if async_call: + with pytest.raises(litellm.BadRequestError, match="previous_response_id") as raised: await litellm.aresponses( model="hosted_vllm/test-model", input="What is my favorite color?", @@ -292,7 +292,8 @@ async def test_unknown_previous_response_fails_before_sending_a_contextless_comp api_base="https://provider.invalid/v1", num_retries=0, ) - else: + else: + with pytest.raises(litellm.BadRequestError, match="previous_response_id") as raised: litellm.responses( model="hosted_vllm/test-model", input="What is my favorite color?",