mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from .helper import PillowTestCase, hopper
|
|
|
|
from PIL import Image
|
|
|
|
import copy
|
|
|
|
|
|
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)
|