mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
tests for basic operations on 0x0 images
This commit is contained in:
parent
69bea50810
commit
0a922b962f
|
@ -78,12 +78,25 @@ class TestImageGetPixel(AccessTest):
|
|||
im.getpixel((0, 0)), c,
|
||||
"put/getpixel roundtrip failed for mode %s, color %s" % (mode, c))
|
||||
|
||||
# Check 0
|
||||
im = Image.new(mode, (0, 0), None)
|
||||
with self.assertRaises(IndexError):
|
||||
im.putpixel((0, 0), c)
|
||||
with self.assertRaises(IndexError):
|
||||
im.getpixel((0, 0))
|
||||
|
||||
# check initial color
|
||||
im = Image.new(mode, (1, 1), c)
|
||||
self.assertEqual(
|
||||
im.getpixel((0, 0)), c,
|
||||
"initial color failed for mode %s, color %s " % (mode, c))
|
||||
|
||||
# Check 0
|
||||
im = Image.new(mode, (0, 0), c)
|
||||
with self.assertRaises(IndexError):
|
||||
im.getpixel((0, 0))
|
||||
|
||||
|
||||
def test_basic(self):
|
||||
for mode in ("1", "L", "LA", "I", "I;16", "I;16B", "F",
|
||||
"P", "PA", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr"):
|
||||
|
|
|
@ -19,6 +19,11 @@ class TestImageConvert(PillowTestCase):
|
|||
for mode in modes:
|
||||
convert(im, mode)
|
||||
|
||||
# Check 0
|
||||
im = Image.new(mode, (0,0))
|
||||
for mode in modes:
|
||||
convert(im, mode)
|
||||
|
||||
def test_default(self):
|
||||
|
||||
im = hopper("P")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import copy
|
||||
|
||||
|
||||
|
@ -33,5 +35,12 @@ class TestImageCopy(PillowTestCase):
|
|||
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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -83,6 +83,23 @@ class TestImageCrop(PillowTestCase):
|
|||
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))
|
||||
|
||||
cropped = im.crop((10, 10, 20, 20))
|
||||
self.assertEqual(cropped.size, (10, 10))
|
||||
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))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -89,6 +89,14 @@ class TestImagingCoreResize(PillowTestCase):
|
|||
# as separately resized channel
|
||||
self.assert_image_equal(ch, references[channels[i]])
|
||||
|
||||
def test_enlarge_zero(self):
|
||||
for f in [Image.NEAREST, Image.BOX, Image.BILINEAR, Image.HAMMING,
|
||||
Image.BICUBIC, Image.LANCZOS]:
|
||||
r = self.resize(Image.new('RGB', (0,0), "white"), (212, 195), f)
|
||||
self.assertEqual(r.mode, "RGB")
|
||||
self.assertEqual(r.size, (212, 195))
|
||||
self.assertEqual(r.getdata()[0], (0,0,0))
|
||||
|
||||
|
||||
class TestImageResize(PillowTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user