mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Added test for crop operation with no argument
This commit is contained in:
parent
296fb5fe1d
commit
c5265e2100
|
@ -7,9 +7,12 @@ class TestImageCrop(PillowTestCase):
|
|||
|
||||
def test_crop(self):
|
||||
def crop(mode):
|
||||
out = hopper(mode).crop((50, 50, 100, 100))
|
||||
self.assertEqual(out.mode, mode)
|
||||
self.assertEqual(out.size, (50, 50))
|
||||
im = hopper(mode)
|
||||
self.assert_image_equal(im.crop(), im)
|
||||
|
||||
cropped = im.crop((50, 50, 100, 100))
|
||||
self.assertEqual(cropped.mode, mode)
|
||||
self.assertEqual(cropped.size, (50, 50))
|
||||
for mode in "1", "P", "L", "RGB", "I", "F":
|
||||
crop(mode)
|
||||
|
||||
|
@ -70,23 +73,23 @@ class TestImageCrop(PillowTestCase):
|
|||
#Image.crop crashes prepatch with an access violation
|
||||
#apparently a use after free on windows, see
|
||||
#https://github.com/python-pillow/Pillow/issues/1077
|
||||
|
||||
|
||||
test_img = 'Tests/images/bmp/g/pal8-0.bmp'
|
||||
extents = (1,1,10,10)
|
||||
#works prepatch
|
||||
img = Image.open(test_img)
|
||||
img2 = img.crop(extents)
|
||||
img2.load()
|
||||
|
||||
|
||||
# fail prepatch
|
||||
img = Image.open(test_img)
|
||||
img = img.crop(extents)
|
||||
img.load()
|
||||
|
||||
def test_crop_zero(self):
|
||||
|
||||
|
||||
im = Image.new('RGB', (0, 0), 'white')
|
||||
|
||||
|
||||
cropped = im.crop((0, 0, 0, 0))
|
||||
self.assertEqual(cropped.size, (0, 0))
|
||||
|
||||
|
@ -95,7 +98,7 @@ class TestImageCrop(PillowTestCase):
|
|||
self.assertEqual(cropped.getdata()[0], (0, 0, 0))
|
||||
|
||||
im = Image.new('RGB', (0, 0))
|
||||
|
||||
|
||||
cropped = im.crop((10, 10, 20, 20))
|
||||
self.assertEqual(cropped.size, (10, 10))
|
||||
self.assertEqual(cropped.getdata()[2], (0, 0, 0))
|
||||
|
|
Loading…
Reference in New Issue
Block a user