diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2008-07-21 11:52:11 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2008-07-21 11:52:11 +0000 |
| commit | 4016d5264ab049c33c845c5337ce2a3e50754268 (patch) | |
| tree | c8e21a5bad768603f314a05792387d0cf84a84a1 /tests | |
| parent | bfcecbffd37a68b5fffe81954c17aedeacb1ba22 (diff) | |
Fixed #7727 -- Improved the checks for import failure when using PIL. Under PyPy, you can import the PIL module, but when you try to use it, the underlying _imaging module will not be available. Thanks to Maciej Fijalkowski (fijal) for the report and suggested fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8016 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/model_forms/models.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py index cc9efd0f94..be2a8ba835 100644 --- a/tests/modeltests/model_forms/models.py +++ b/tests/modeltests/model_forms/models.py @@ -69,8 +69,10 @@ class ImageFile(models.Model): description = models.CharField(max_length=20) try: # If PIL is available, try testing PIL. - # Otherwise, it's equivalent to TextFile above. - import Image + # Checking for the existence of Image is enough for CPython, but + # for PyPy, you need to check for the underlying modules + # If PIL is not available, this test is equivalent to TextFile above. + import Image, _imaging image = models.ImageField(upload_to=tempfile.gettempdir()) except ImportError: image = models.FileField(upload_to=tempfile.gettempdir()) |
