summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorDaniel Lindsley <daniel@toastdriven.com>2013-05-14 19:31:16 -0700
committerDaniel Lindsley <daniel@toastdriven.com>2013-05-14 19:32:04 -0700
commit33793f7c3edd8ff144ff2e9434367267c20af26a (patch)
tree2fc05d98ee3d9c2bb9fd9a208647ad280d52b78c /tests/model_fields
parentc792c83cad54f064b6ba13e285e95a90e2c61f09 (diff)
Fixed #19934 - Use of Pillow is now preferred over PIL.
This starts the deprecation period for PIL (support to end in 1.8).
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/models.py17
-rw-r--r--tests/model_fields/test_imagefield.py8
2 files changed, 12 insertions, 13 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index c3b2f7fccb..2d602d6412 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -1,17 +1,12 @@
import os
import tempfile
-# Try to import PIL in either of the two ways it can end up installed.
-# Checking for the existence of Image is enough for CPython, but for PyPy,
-# you need to check for the underlying modules.
+from django.core.exceptions import ImproperlyConfigured
try:
- from PIL import Image, _imaging
-except ImportError:
- try:
- import Image, _imaging
- except ImportError:
- Image = None
+ from django.utils.image import Image
+except ImproperlyConfigured:
+ Image = None
from django.core.files.storage import FileSystemStorage
from django.db import models
@@ -87,7 +82,7 @@ class VerboseNameField(models.Model):
field9 = models.FileField("verbose field9", upload_to="unused")
field10 = models.FilePathField("verbose field10")
field11 = models.FloatField("verbose field11")
- # Don't want to depend on PIL in this test
+ # Don't want to depend on Pillow/PIL in this test
#field_image = models.ImageField("verbose field")
field12 = models.IntegerField("verbose field12")
field13 = models.IPAddressField("verbose field13")
@@ -119,7 +114,7 @@ class Document(models.Model):
###############################################################################
# ImageField
-# If PIL available, do these tests.
+# If Pillow/PIL available, do these tests.
if Image:
class TestImageFieldFile(ImageFieldFile):
"""
diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py
index df0215db3d..457892ddb8 100644
--- a/tests/model_fields/test_imagefield.py
+++ b/tests/model_fields/test_imagefield.py
@@ -3,20 +3,24 @@ from __future__ import absolute_import
import os
import shutil
+from django.core.exceptions import ImproperlyConfigured
from django.core.files import File
from django.core.files.images import ImageFile
from django.test import TestCase
from django.utils._os import upath
from django.utils.unittest import skipIf
-from .models import Image
+try:
+ from .models import Image
+except ImproperlyConfigured:
+ Image = None
if Image:
from .models import (Person, PersonWithHeight, PersonWithHeightAndWidth,
PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile)
from .models import temp_storage_dir
else:
- # PIL not available, create dummy classes (tests will be skipped anyway)
+ # Pillow not available, create dummy classes (tests will be skipped anyway)
class Person():
pass
PersonWithHeight = PersonWithHeightAndWidth = PersonDimensionsFirst = Person