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.
This commit is contained in:
Ishaan Jaffer 2026-03-07 16:57:30 -08:00
parent 34984d22ae
commit 5f7becf82d

View file

@ -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