summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYosuke Yasuda <double.y.919.quick@gmail.com>2015-07-12 12:48:13 +0900
committerTim Graham <timograham@gmail.com>2015-07-13 14:58:44 -0400
commita2b999dfcac9bc92513a36ec6b3033ded1561c66 (patch)
tree728e9f7ec2bd099f1a087db0ea4f024580d8f45a
parent97bc875234c5578a16e9e89be2b3431153e7b413 (diff)
Fixed #25108 -- Fixed a test which failed on Pillow 2.9+
-rw-r--r--tests/forms_tests/tests/test_fields.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index bfc88d7162..9c341ca7a3 100644
--- a/tests/forms_tests/tests/test_fields.py
+++ b/tests/forms_tests/tests/test_fields.py
@@ -847,19 +847,23 @@ class FieldsTests(SimpleTestCase):
This also tests the situation when Pillow doesn't detect the MIME type
of the image (#24948).
"""
- f = ImageField()
-
- img_path = os.path.dirname(upath(__file__)) + '/filepath_test_files/1x1.bmp'
- with open(img_path, 'rb') as img_file:
- img_data = img_file.read()
+ from PIL.BmpImagePlugin import BmpImageFile
+ try:
+ Image.register_mime(BmpImageFile.format, None)
+ f = ImageField()
+ img_path = os.path.dirname(upath(__file__)) + '/filepath_test_files/1x1.bmp'
+ with open(img_path, 'rb') as img_file:
+ img_data = img_file.read()
- img_file = SimpleUploadedFile('1x1.bmp', img_data)
- img_file.content_type = 'text/plain'
+ img_file = SimpleUploadedFile('1x1.bmp', img_data)
+ img_file.content_type = 'text/plain'
- uploaded_file = f.clean(img_file)
+ uploaded_file = f.clean(img_file)
- self.assertEqual('BMP', uploaded_file.image.format)
- self.assertIsNone(uploaded_file.content_type)
+ self.assertEqual('BMP', uploaded_file.image.format)
+ self.assertIsNone(uploaded_file.content_type)
+ finally:
+ Image.register_mime(BmpImageFile.format, 'image/bmp')
# URLField ##################################################################