mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24441 -- Changed get_image_dimensions() return value for broken images
This commit is contained in:
committed by
Tim Graham
parent
cb506aed2a
commit
cda74c7fc9
@@ -239,6 +239,22 @@ class InconsistentGetImageDimensionsBug(unittest.TestCase):
|
||||
self.assertEqual(size, Image.open(fh).size)
|
||||
|
||||
|
||||
class GetImageDimensionsOnInvalidImages(unittest.TestCase):
|
||||
@unittest.skipUnless(Image, "Pillow not installed")
|
||||
def test_invalid_image(self):
|
||||
"""
|
||||
get_image_dimensions() should return (None, None) for the dimensions of
|
||||
invalid images (#24441).
|
||||
|
||||
brokenimg.png is not a valid image and it has been generated by:
|
||||
$ echo "123" > brokenimg.png
|
||||
"""
|
||||
img_path = os.path.join(os.path.dirname(upath(__file__)), "brokenimg.png")
|
||||
with open(img_path, 'rb') as fh:
|
||||
size = images.get_image_dimensions(fh)
|
||||
self.assertEqual(size, (None, None))
|
||||
|
||||
|
||||
class FileMoveSafeTests(unittest.TestCase):
|
||||
def test_file_move_overwrite(self):
|
||||
handle_a, self.file_a = tempfile.mkstemp()
|
||||
|
||||
Reference in New Issue
Block a user