1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00

Refs #21286 -- Fixed serializers tests if Pillow isn't installed.

This commit is contained in:
Mariusz Felisiak 2024-12-05 08:08:09 +01:00 committed by Sarah Boyce
parent eb665e076c
commit 3d508ececb
2 changed files with 18 additions and 7 deletions

View File

@ -13,6 +13,15 @@ from django.db import models
from .base import BaseModel
try:
from PIL import Image # NOQA
except ImportError:
ImageData = None
else:
class ImageData(models.Model):
data = models.ImageField(null=True)
class BinaryData(models.Model):
data = models.BinaryField(null=True)
@ -62,10 +71,6 @@ class BigIntegerData(models.Model):
data = models.BigIntegerField(null=True)
class ImageData(models.Model):
data = models.ImageField(null=True)
class GenericIPAddressData(models.Model):
data = models.GenericIPAddressField(null=True)

View File

@ -292,9 +292,6 @@ test_data = [
(data_obj, 81, IntegerData, -123456789),
(data_obj, 82, IntegerData, 0),
(data_obj, 83, IntegerData, None),
(data_obj, 86, ImageData, "file:///foo/bar/whiz.png"),
# (data_obj, 87, ImageData, None),
(data_obj, 88, ImageData, ""),
(data_obj, 95, GenericIPAddressData, "fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"),
(data_obj, 96, GenericIPAddressData, None),
(data_obj, 110, PositiveBigIntegerData, 9223372036854775807),
@ -408,6 +405,15 @@ The end.""",
(data_obj, 1005, LengthModel, 1),
]
if ImageData is not None:
test_data.extend(
[
(data_obj, 86, ImageData, "file:///foo/bar/whiz.png"),
# (data_obj, 87, ImageData, None),
(data_obj, 88, ImageData, ""),
]
)
class SerializerDataTests(TestCase):
pass