Mode F and I tests for Image.putdata

This commit is contained in:
wiredfool 2014-07-28 22:09:52 -07:00
parent 78d2618064
commit 1a245a577b

View File

@ -46,6 +46,26 @@ class TestImagePutData(PillowTestCase):
im = Image.new('L', (256,256))
im.putdata(list(range(256))*256)
def test_mode_i(self):
src = lena('L')
data = list(src.getdata())
im = Image.new('I', src.size, 0)
im.putdata(data, 2, 256)
target = [2* elt + 256 for elt in data]
self.assertEqual(list(im.getdata()), target)
def test_mode_F(self):
src = lena('L')
data = list(src.getdata())
im = Image.new('F', src.size, 0)
im.putdata(data, 2.0, 256.0)
target = [2.0* float(elt) + 256.0 for elt in data]
self.assertEqual(list(im.getdata()), target)
if __name__ == '__main__':
unittest.main()