From 71d77c489b7c2a497eb95748039a6e5f37d2b4a9 Mon Sep 17 00:00:00 2001 From: Shin Date: Sun, 1 Feb 2026 23:01:53 +0000 Subject: [PATCH] fix(test): use patch.object for reliable module attribute patching in cold storage test The test was using patch('litellm.cold_storage_custom_logger', return_value='s3') which creates a MagicMock object. While this works in most environments, it can behave inconsistently in certain CI environments. Changed to patch.object(litellm, 'cold_storage_custom_logger', 's3') which directly sets the attribute value and ensures consistent behavior across all test environments. Fixes test_should_check_cold_storage_for_full_payload in litellm_mapped_tests_core --- .../litellm_completion_transformation/test_session_handler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_session_handler.py b/tests/test_litellm/responses/litellm_completion_transformation/test_session_handler.py index b0a232a7bf4..2ec81dbfe0f 100644 --- a/tests/test_litellm/responses/litellm_completion_transformation/test_session_handler.py +++ b/tests/test_litellm/responses/litellm_completion_transformation/test_session_handler.py @@ -343,7 +343,9 @@ async def test_should_check_cold_storage_for_full_payload(): # Test case 4: None request (should return True) proxy_request_none = None - with patch("litellm.cold_storage_custom_logger", return_value="s3"): + # Use patch.object to properly set the attribute value (not a mock) + # This ensures consistent behavior across all test environments + with patch.object(litellm, 'cold_storage_custom_logger', 's3'): # Test case 1: Should return True for truncated content result1 = ResponsesSessionHandler._should_check_cold_storage_for_full_payload(proxy_request_with_truncated_pdf) assert result1 == True, "Should return True for proxy request with truncated PDF content"