From 660f760f93c4c32bbf368bf2f799531a33609a3b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 7 Mar 2026 03:20:45 +0000 Subject: [PATCH] fix: patch HTTPHandler class-level in VLLM embedding test The test_encoding_format_not_sent_in_actual_request test was patching client.post on an instance, but the handler uses the class method. Patch HTTPHandler.post at class level, add caching=False to prevent cache hits, and remove broad try/except that hid errors. Co-authored-by: Ishaan Jaff --- ...st_hosted_vllm_embedding_transformation.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_litellm/llms/hosted_vllm/embedding/test_hosted_vllm_embedding_transformation.py b/tests/test_litellm/llms/hosted_vllm/embedding/test_hosted_vllm_embedding_transformation.py index 4cb20154570..008f5aa11a2 100644 --- a/tests/test_litellm/llms/hosted_vllm/embedding/test_hosted_vllm_embedding_transformation.py +++ b/tests/test_litellm/llms/hosted_vllm/embedding/test_hosted_vllm_embedding_transformation.py @@ -235,14 +235,16 @@ class TestHostedVLLMEmbeddingTransformation: def test_encoding_format_not_sent_in_actual_request(self): """ E2E test that encoding_format is not sent when not provided. - + This test mocks the HTTP client to verify the actual request payload. + Patches HTTPHandler.post at the class level so the mock is used when + base_llm_http_handler calls sync_httpx_client.post() with the passed client. """ from litellm.llms.custom_httpx.http_handler import HTTPHandler client = HTTPHandler() - - with patch.object(client, "post") as mock_post: + + with patch.object(HTTPHandler, "post") as mock_post: # Mock response mock_response = Mock() mock_response.status_code = 200 @@ -265,15 +267,13 @@ class TestHostedVLLMEmbeddingTransformation: mock_response.text = json.dumps(mock_response.json.return_value) mock_post.return_value = mock_response - try: - litellm.embedding( - model=self.model, - input=["Hello world"], - api_base="https://test-vllm.example.com/v1", - client=client, - ) - except Exception: - pass + litellm.embedding( + model=self.model, + input=["Hello world"], + api_base="https://test-vllm.example.com/v1", + client=client, + caching=False, + ) # Verify the request was made mock_post.assert_called_once()