mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 02:46:18 +03:00
d50445ff30
Similar to the recent adoption of Black. isort is a Python utility to sort imports alphabetically and automatically separate into sections. By using isort, contributors can quickly and automatically conform to the projects style without thinking. Just let the tool do it. Uses the configuration recommended by the Black to avoid conflicts of style. Rewrite TestImageQt.test_deprecated to no rely on import order.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import copy
|
|
|
|
from PIL import Image
|
|
|
|
from .helper import PillowTestCase, hopper
|
|
|
|
|
|
class TestImageCopy(PillowTestCase):
|
|
def test_copy(self):
|
|
croppedCoordinates = (10, 10, 20, 20)
|
|
croppedSize = (10, 10)
|
|
for mode in "1", "P", "L", "RGB", "I", "F":
|
|
# Internal copy method
|
|
im = hopper(mode)
|
|
out = im.copy()
|
|
self.assertEqual(out.mode, im.mode)
|
|
self.assertEqual(out.size, im.size)
|
|
|
|
# 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)
|
|
|
|
def test_copy_zero(self):
|
|
im = Image.new("RGB", (0, 0))
|
|
out = im.copy()
|
|
self.assertEqual(out.mode, im.mode)
|
|
self.assertEqual(out.size, im.size)
|