Made an expressions_case test work without Pillow.

This commit is contained in:
Collin Anderson 2015-01-15 12:40:31 -05:00 committed by Tim Graham
parent 47bdad4e6b
commit 67dbc56ec8
2 changed files with 14 additions and 1 deletions

View File

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

View File

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