From 5f7becf82d66df125c5c4382f357a5d7a57df2f7 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 7 Mar 2026 16:57:30 -0800 Subject: [PATCH] fix(tests): generate square PNG in image_url fixture for DALL-E 2 variation test DALL-E 2 create_variation requires a square PNG. The old fixture fetched the LiteLLM logo from S3 which is non-square, causing API rejections. Replace with a programmatically-generated 1024x1024 RGBA PNG via Pillow. --- tests/image_gen_tests/test_image_variation.py | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/image_gen_tests/test_image_variation.py b/tests/image_gen_tests/test_image_variation.py index 4f2d7c2b13d..c0ad5d38e66 100644 --- a/tests/image_gen_tests/test_image_variation.py +++ b/tests/image_gen_tests/test_image_variation.py @@ -27,25 +27,21 @@ import tempfile from base_image_generation_test import BaseImageGenTest import logging from litellm._logging import verbose_logger -import requests from io import BytesIO +from PIL import Image as PILImage verbose_logger.setLevel(logging.DEBUG) @pytest.fixture def image_url(): - # URL of the image - image_url = "https://litellm-listing.s3.amazonaws.com/litellm_logo.png" - - # Fetch the image from the URL - response = requests.get(image_url) - print(response) - response.raise_for_status() # Ensure the request was successful - - # Load the image into a file-like object - image_file = BytesIO(response.content) - image_file.name = "litellm_logo.png" + # DALL-E 2 image variations require a square PNG (less than 4MB) + # Generate a 1024x1024 square PNG programmatically to avoid network dependency + # and the non-square aspect ratio of the old LiteLLM logo URL + img = PILImage.new("RGBA", (1024, 1024), color=(128, 128, 128, 255)) + image_file = BytesIO() + img.save(image_file, format="PNG") + image_file.seek(0) return image_file