mirror of
https://github.com/django/django.git
synced 2025-03-12 18:30:48 +00:00
[1.8.x] Fixed #25108 -- Fixed a test which failed on Pillow 2.9+
Backport of a2b999dfcac9bc92513a36ec6b3033ded1561c66 from master
This commit is contained in:
parent
f8140c4679
commit
269315d81a
@ -812,19 +812,23 @@ class FieldsTests(SimpleTestCase):
|
|||||||
This also tests the situation when Pillow doesn't detect the MIME type
|
This also tests the situation when Pillow doesn't detect the MIME type
|
||||||
of the image (#24948).
|
of the image (#24948).
|
||||||
"""
|
"""
|
||||||
f = ImageField()
|
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_path = os.path.dirname(upath(__file__)) + '/filepath_test_files/1x1.bmp'
|
img_file = SimpleUploadedFile('1x1.bmp', img_data)
|
||||||
with open(img_path, 'rb') as img_file:
|
img_file.content_type = 'text/plain'
|
||||||
img_data = img_file.read()
|
|
||||||
|
|
||||||
img_file = SimpleUploadedFile('1x1.bmp', img_data)
|
uploaded_file = f.clean(img_file)
|
||||||
img_file.content_type = 'text/plain'
|
|
||||||
|
|
||||||
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)
|
finally:
|
||||||
self.assertIsNone(uploaded_file.content_type)
|
Image.register_mime(BmpImageFile.format, 'image/bmp')
|
||||||
|
|
||||||
# URLField ##################################################################
|
# URLField ##################################################################
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user