Ticket #11158: 11158_test.diff

File 11158_test.diff, 1.1 KB (added by SAn, 5 years ago)

test case

  • tests/regressiontests/file_storage/tests.py

    diff -r e5a120cb280b -r 1c91caa5f2d8 tests/regressiontests/file_storage/tests.py
    a b  
    230230            finally:
    231231                del images.open
    232232            self.assert_(FileWrapper._closed)
     233
     234    class InconsistentGetImageDimensionsBug(TestCase):
     235        """
     236        Test that get_image_dimensions() works properly after various calls using a file handler (#11158)
     237        """
     238        def test_multiple_calls(self):
     239            """
     240            Multiple calls of get_image_dimensions() should return the same size.
     241            """
     242            from django.core.files.images import ImageFile
     243            img_path = os.path.join(os.path.dirname(__file__), "test.png")
     244            image = ImageFile(open(img_path))
     245            image_pil = Image.open(img_path)
     246            size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image)
     247            self.assertEqual(image_pil.size, size_1)
     248            self.assertEqual(size_1, size_2)
Back to Top