Merge some similar tests to a single file

This commit is contained in:
hugovk 2014-07-20 00:51:26 +03:00
parent 0c12058e37
commit 15c92359cc
6 changed files with 41 additions and 96 deletions

View File

@ -29,6 +29,10 @@ class TestImageFilter(PillowTestCase):
filter(ImageFilter.MinFilter)
filter(ImageFilter.ModeFilter)
filter(ImageFilter.Kernel((3, 3), list(range(9))))
filter(ImageFilter.GaussianBlur)
filter(ImageFilter.GaussianBlur(5))
filter(ImageFilter.UnsharpMask)
filter(ImageFilter.UnsharpMask(10))
self.assertRaises(TypeError, lambda: filter("hello"))

View File

@ -10,6 +10,27 @@ class TestImageMode(PillowTestCase):
im = lena()
im.mode
from PIL import ImageMode
ImageMode.getmode("1")
ImageMode.getmode("L")
ImageMode.getmode("P")
ImageMode.getmode("RGB")
ImageMode.getmode("I")
ImageMode.getmode("F")
m = ImageMode.getmode("1")
self.assertEqual(m.mode, "1")
self.assertEqual(m.bands, ("1",))
self.assertEqual(m.basemode, "L")
self.assertEqual(m.basetype, "L")
m = ImageMode.getmode("RGB")
self.assertEqual(m.mode, "RGB")
self.assertEqual(m.bands, ("R", "G", "B"))
self.assertEqual(m.basemode, "RGB")
self.assertEqual(m.basetype, "L")
def test_properties(self):
def check(mode, *result):
signature = (

View File

@ -5,6 +5,22 @@ from PIL import Image
class TestImageTransform(PillowTestCase):
def test_sanity(self):
from PIL import ImageTransform
im = Image.new("L", (100, 100))
seq = tuple(range(10))
transform = ImageTransform.AffineTransform(seq[:6])
im.transform((100, 100), transform)
transform = ImageTransform.ExtentTransform(seq[:4])
im.transform((100, 100), transform)
transform = ImageTransform.QuadTransform(seq[:8])
im.transform((100, 100), transform)
transform = ImageTransform.MeshTransform([(seq[:4], seq[:8])])
im.transform((100, 100), transform)
def test_extent(self):
im = lena('RGB')
(w, h) = im.size

View File

@ -1,37 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import ImageFilter
class TestImageFilter(PillowTestCase):
def test_sanity(self):
# see test_image_filter for more tests
# Check these run. Exceptions cause failures.
ImageFilter.MaxFilter
ImageFilter.MedianFilter
ImageFilter.MinFilter
ImageFilter.ModeFilter
ImageFilter.Kernel((3, 3), list(range(9)))
ImageFilter.GaussianBlur
ImageFilter.GaussianBlur(5)
ImageFilter.UnsharpMask
ImageFilter.UnsharpMask(10)
ImageFilter.BLUR
ImageFilter.CONTOUR
ImageFilter.DETAIL
ImageFilter.EDGE_ENHANCE
ImageFilter.EDGE_ENHANCE_MORE
ImageFilter.EMBOSS
ImageFilter.FIND_EDGES
ImageFilter.SMOOTH
ImageFilter.SMOOTH_MORE
ImageFilter.SHARPEN
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -1,32 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import ImageMode
class TestImageMode(PillowTestCase):
def test_sanity(self):
ImageMode.getmode("1")
ImageMode.getmode("L")
ImageMode.getmode("P")
ImageMode.getmode("RGB")
ImageMode.getmode("I")
ImageMode.getmode("F")
m = ImageMode.getmode("1")
self.assertEqual(m.mode, "1")
self.assertEqual(m.bands, ("1",))
self.assertEqual(m.basemode, "L")
self.assertEqual(m.basetype, "L")
m = ImageMode.getmode("RGB")
self.assertEqual(m.mode, "RGB")
self.assertEqual(m.bands, ("R", "G", "B"))
self.assertEqual(m.basemode, "RGB")
self.assertEqual(m.basetype, "L")
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -1,27 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import Image
from PIL import ImageTransform
class TestImageTransform(PillowTestCase):
def test_sanity(self):
im = Image.new("L", (100, 100))
seq = tuple(range(10))
transform = ImageTransform.AffineTransform(seq[:6])
im.transform((100, 100), transform)
transform = ImageTransform.ExtentTransform(seq[:4])
im.transform((100, 100), transform)
transform = ImageTransform.QuadTransform(seq[:8])
im.transform((100, 100), transform)
transform = ImageTransform.MeshTransform([(seq[:4], seq[:8])])
im.transform((100, 100), transform)
if __name__ == '__main__':
unittest.main()
# End of file