Made an expressions_case test work without Pillow.
This commit is contained in:
parent
47bdad4e6b
commit
67dbc56ec8
|
@ -3,6 +3,11 @@ from __future__ import unicode_literals
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
try:
|
||||||
|
from PIL import Image
|
||||||
|
except ImportError:
|
||||||
|
Image = None
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class CaseTestModel(models.Model):
|
class CaseTestModel(models.Model):
|
||||||
|
@ -22,7 +27,8 @@ class CaseTestModel(models.Model):
|
||||||
file = models.FileField(null=True, db_column='file_field')
|
file = models.FileField(null=True, db_column='file_field')
|
||||||
file_path = models.FilePathField(null=True)
|
file_path = models.FilePathField(null=True)
|
||||||
float = models.FloatField(null=True, db_column='float_field')
|
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)
|
ip_address = models.IPAddressField(null=True)
|
||||||
generic_ip_address = models.GenericIPAddressField(null=True)
|
generic_ip_address = models.GenericIPAddressField(null=True)
|
||||||
null_boolean = models.NullBooleanField()
|
null_boolean = models.NullBooleanField()
|
||||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from operator import attrgetter, itemgetter
|
from operator import attrgetter, itemgetter
|
||||||
|
import unittest
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from django.core.exceptions import FieldError
|
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.test import TestCase
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
|
try:
|
||||||
|
from PIL import Image
|
||||||
|
except ImportError:
|
||||||
|
Image = None
|
||||||
|
|
||||||
from .models import CaseTestModel, O2OCaseTestModel, FKCaseTestModel, Client
|
from .models import CaseTestModel, O2OCaseTestModel, FKCaseTestModel, Client
|
||||||
|
|
||||||
|
|
||||||
|
@ -726,6 +732,7 @@ class CaseExpressionTests(TestCase):
|
||||||
transform=attrgetter('integer', 'float')
|
transform=attrgetter('integer', 'float')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@unittest.skipUnless(Image, "Pillow not installed")
|
||||||
def test_update_image(self):
|
def test_update_image(self):
|
||||||
CaseTestModel.objects.update(
|
CaseTestModel.objects.update(
|
||||||
image=Case(
|
image=Case(
|
||||||
|
|
Loading…
Reference in New Issue