From 8fa1ed4066f857555f9f73cade43708ee12a3ab1 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 28 Oct 2026 08:57:00 +0000 Subject: [PATCH] test: drop duplicate guard assertions Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../test_anthropic_chat_transformation.py | 15 ------------ .../chat/test_converse_transformation.py | 24 ++++--------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py index 09933605ade..1c748f0c83d 100644 --- a/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/unit/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -9756,14 +9756,6 @@ def test_json_mode_text_without_tool_call_is_unchanged(): assert message.tool_calls is None assert "json_mode_preamble_text" not in (message.provider_specific_fields or {}) - preamble: Final = "Let me answer the question. " - json_result: Final = _transform_json_mode_body( - {**body, "content": [{"type": "text", "text": preamble}, *body["content"]]} - ) - json_message: Final = json_result.choices[0].message - assert json_message.content == '{"answer": "Hello"}' - assert json_message.provider_specific_fields["json_mode_preamble_text"] == preamble - def test_json_mode_with_a_real_tool_keeps_mixed_response_behavior(): preamble: Final = "I will look up the details. " @@ -9786,13 +9778,6 @@ def test_json_mode_with_a_real_tool_keeps_mixed_response_behavior(): assert message.tool_calls[0].function.arguments == '{"location": "San Francisco"}' assert "json_mode_preamble_text" not in (message.provider_specific_fields or {}) - json_result: Final = _transform_json_mode_body( - {**body, "content": [{"type": "text", "text": preamble}, *body["content"]]} - ) - json_message: Final = json_result.choices[0].message - assert json_message.content == '{"answer": "Hello"}' - assert json_message.provider_specific_fields["json_mode_preamble_text"] == preamble - def test_non_dict_upstream_body_still_transforms_without_refusal_fields() -> None: result = AnthropicConfig().transform_parsed_response( diff --git a/tests/unit/llms/bedrock/chat/test_converse_transformation.py b/tests/unit/llms/bedrock/chat/test_converse_transformation.py index fcdddb6daac..143f0981814 100644 --- a/tests/unit/llms/bedrock/chat/test_converse_transformation.py +++ b/tests/unit/llms/bedrock/chat/test_converse_transformation.py @@ -6795,7 +6795,7 @@ def test_bedrock_json_mode_preserves_nonblank_text_before_json_tool_call(): def test_bedrock_json_mode_omits_whitespace_only_preamble(): - whitespace_result: Final = _transform_json_mode_content_blocks( + result: Final = _transform_json_mode_content_blocks( [ {"text": " \n\t"}, { @@ -6808,25 +6808,9 @@ def test_bedrock_json_mode_omits_whitespace_only_preamble(): ] ) - whitespace_message: Final = whitespace_result.choices[0].message - assert whitespace_message.content == '{"answer": 42}' - assert "json_mode_preamble_text" not in (whitespace_message.provider_specific_fields or {}) - - preamble: Final = "Here is the answer. " - nonblank_result: Final = _transform_json_mode_content_blocks( - [ - {"text": preamble}, - { - "toolUse": { - "toolUseId": "tooluse_json_001", - "name": "json_tool_call", - "input": {"answer": 42}, - } - }, - ] - ) - nonblank_message: Final = nonblank_result.choices[0].message - assert nonblank_message.provider_specific_fields["json_mode_preamble_text"] == preamble + message: Final = result.choices[0].message + assert message.content == '{"answer": 42}' + assert "json_mode_preamble_text" not in (message.provider_specific_fields or {}) def test_bedrock_json_mode_preamble_preserves_reasoning_content_fields():