mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Test for issue #1008
This commit is contained in:
parent
482f658704
commit
a105cd7edb
|
@ -1,4 +1,5 @@
|
|||
from helper import unittest, PillowTestCase, hopper
|
||||
from array import array
|
||||
|
||||
import sys
|
||||
|
||||
|
@ -63,6 +64,25 @@ class TestImagePutData(PillowTestCase):
|
|||
target = [2.0 * float(elt) + 256.0 for elt in data]
|
||||
self.assertEqual(list(im.getdata()), target)
|
||||
|
||||
def test_array_B(self):
|
||||
# shouldn't segfault
|
||||
# see https://github.com/python-pillow/Pillow/issues/1008
|
||||
|
||||
arr = array('B', [0])*15000
|
||||
im = Image.new('L', (150, 100))
|
||||
im.putdata(arr)
|
||||
|
||||
self.assertEqual(len(im.getdata()),len(arr))
|
||||
|
||||
def test_array_F(self):
|
||||
# shouldn't segfault
|
||||
# see https://github.com/python-pillow/Pillow/issues/1008
|
||||
|
||||
im = Image.new('F', (150, 100))
|
||||
arr = array('f', [0.0])*15000
|
||||
im.putdata(arr)
|
||||
|
||||
self.assertEqual(len(im.getdata()),len(arr))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -121,6 +121,16 @@ class TestNumpy(PillowTestCase):
|
|||
|
||||
im.point(lut)
|
||||
|
||||
def test_putdata(self):
|
||||
# shouldn't segfault
|
||||
# see https://github.com/python-pillow/Pillow/issues/1008
|
||||
|
||||
im = Image.new('F', (150, 100))
|
||||
arr = numpy.zeros((15000,), numpy.float32)
|
||||
im.putdata(arr)
|
||||
|
||||
self.assertEqual(len(im.getdata()),len(arr))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user