Code

Ticket #11158: 11158_test.diff

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

test case

Line 
1diff -r e5a120cb280b -r 1c91caa5f2d8 tests/regressiontests/file_storage/tests.py
2--- a/tests/regressiontests/file_storage/tests.py       Sat Mar 06 15:50:12 2010 +0000
3+++ b/tests/regressiontests/file_storage/tests.py       Sat Mar 06 17:00:35 2010 -0300
4@@ -230,3 +230,19 @@
5             finally:
6                 del images.open
7             self.assert_(FileWrapper._closed)
8+
9+    class InconsistentGetImageDimensionsBug(TestCase):
10+        """
11+        Test that get_image_dimensions() works properly after various calls using a file handler (#11158)
12+        """
13+        def test_multiple_calls(self):
14+            """
15+            Multiple calls of get_image_dimensions() should return the same size.
16+            """
17+            from django.core.files.images import ImageFile
18+            img_path = os.path.join(os.path.dirname(__file__), "test.png")
19+            image = ImageFile(open(img_path))
20+            image_pil = Image.open(img_path)
21+            size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image)
22+            self.assertEqual(image_pil.size, size_1)
23+            self.assertEqual(size_1, size_2)