From af75f7ab40f0778a82dbc93f887837c82f02aa8e Mon Sep 17 00:00:00 2001 From: homm Date: Mon, 4 Jul 2016 13:42:45 +0300 Subject: [PATCH] test for reference counting --- Tests/test_image_access.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index c34cf9707..40f648f27 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -221,6 +221,17 @@ class TestCffi(AccessTest): # im = Image.new('I;32B', (10, 10), 2**10) # self._test_set_access(im, 2**13-1) + # ref https://github.com/python-pillow/Pillow/pull/2009 + def test_reference_counting(self): + size = 10 + + for _ in range(10): + # Do not save references to the image, only to the access object + px = Image.new('L', (size, 1), 0).load() + for i in range(size): + # pixels can contain garbarge if image is released + self.assertEqual(px[i, 0], 0) + if __name__ == '__main__': unittest.main()