diff --git a/tests/expressions_case/models.py b/tests/expressions_case/models.py index fcee0cdbd3..b1b24e05fa 100644 --- a/tests/expressions_case/models.py +++ b/tests/expressions_case/models.py @@ -3,6 +3,11 @@ from __future__ import unicode_literals from django.db import models from django.utils.encoding import python_2_unicode_compatible +try: + from PIL import Image +except ImportError: + Image = None + @python_2_unicode_compatible class CaseTestModel(models.Model): @@ -22,7 +27,8 @@ class CaseTestModel(models.Model): file = models.FileField(null=True, db_column='file_field') file_path = models.FilePathField(null=True) float = models.FloatField(null=True, db_column='float_field') - image = models.ImageField(null=True) + if Image: + image = models.ImageField(null=True) ip_address = models.IPAddressField(null=True) generic_ip_address = models.GenericIPAddressField(null=True) null_boolean = models.NullBooleanField() diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index 20bdb840fa..a344e79923 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from datetime import date, datetime, time, timedelta from decimal import Decimal from operator import attrgetter, itemgetter +import unittest from uuid import UUID from django.core.exceptions import FieldError @@ -12,6 +13,11 @@ from django.db.models.expressions import Case, When from django.test import TestCase from django.utils import six +try: + from PIL import Image +except ImportError: + Image = None + from .models import CaseTestModel, O2OCaseTestModel, FKCaseTestModel, Client @@ -726,6 +732,7 @@ class CaseExpressionTests(TestCase): transform=attrgetter('integer', 'float') ) + @unittest.skipUnless(Image, "Pillow not installed") def test_update_image(self): CaseTestModel.objects.update( image=Case(