Pillow/Tests/test_image_copy.py

38 lines
1.1 KiB
Python
Raw Normal View History

from helper import unittest, PillowTestCase, hopper
2016-03-16 12:23:51 +03:00
import copy
2014-06-10 13:10:47 +04:00
class TestImageCopy(PillowTestCase):
def test_copy(self):
2016-03-16 12:23:51 +03:00
croppedCoordinates = (10, 10, 20, 20)
croppedSize = (10, 10)
for mode in "1", "P", "L", "RGB", "I", "F":
# Internal copy method
im = hopper(mode)
2014-06-10 13:10:47 +04:00
out = im.copy()
2016-03-16 12:23:51 +03:00
self.assertEqual(out.mode, im.mode)
2014-06-10 13:10:47 +04:00
self.assertEqual(out.size, im.size)
2016-03-16 12:23:51 +03:00
# Python's copy method
im = hopper(mode)
out = copy.copy(im)
self.assertEqual(out.mode, im.mode)
self.assertEqual(out.size, im.size)
# Internal copy method on a cropped image
im = hopper(mode)
out = im.crop(croppedCoordinates).copy()
self.assertEqual(out.mode, im.mode)
self.assertEqual(out.size, croppedSize)
# Python's copy method on a cropped image
im = hopper(mode)
out = copy.copy(im.crop(croppedCoordinates))
self.assertEqual(out.mode, im.mode)
self.assertEqual(out.size, croppedSize)
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()