Skip to content

Commit 47e390c

Browse files
committed
Use PIL image in test fixture
1 parent 977164d commit 47e390c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

api/tests/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import io
2+
from PIL import Image
13
import pytest
24
import random
35

@@ -27,8 +29,13 @@ def app_user(user_password):
2729
@pytest.fixture
2830
def dummy_image():
2931
# Prepare a fake image file
30-
image_content = b"fake image content" # Replace with actual binary data if needed
31-
test_image = SimpleUploadedFile("test_image.jpg", image_content, content_type="image/jpeg")
32+
# Create a simple image using Pillow
33+
img = Image.new("RGB", (100, 100), color=(73, 109, 137)) # Create a 100x100 image with a specific color
34+
img_byte_arr = io.BytesIO()
35+
img.save(img_byte_arr, format='JPEG') # Save the image in JPEG format
36+
img_byte_arr.seek(0) # Move to the beginning of the BytesIO buffer
37+
38+
test_image = SimpleUploadedFile("test_image.jpg", img_byte_arr.read(), content_type="image/jpeg")
3239

3340
return test_image
3441

0 commit comments

Comments
 (0)