From 15c92359ccf750d79b3474b95aa815149564f15f Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 20 Jul 2014 00:51:26 +0300 Subject: [PATCH] Merge some similar tests to a single file --- Tests/test_image_filter.py | 4 ++++ Tests/test_image_mode.py | 21 ++++++++++++++++++++ Tests/test_image_transform.py | 16 +++++++++++++++ Tests/test_imagefilter.py | 37 ----------------------------------- Tests/test_imagemode.py | 32 ------------------------------ Tests/test_imagetransform.py | 27 ------------------------- 6 files changed, 41 insertions(+), 96 deletions(-) delete mode 100644 Tests/test_imagefilter.py delete mode 100644 Tests/test_imagemode.py delete mode 100644 Tests/test_imagetransform.py diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index 4a85b0a2e..2452479cc 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -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")) diff --git a/Tests/test_image_mode.py b/Tests/test_image_mode.py index 25c35c607..74ed9b7aa 100644 --- a/Tests/test_image_mode.py +++ b/Tests/test_image_mode.py @@ -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 = ( diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 1873ee9a4..42a3d78f3 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -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 diff --git a/Tests/test_imagefilter.py b/Tests/test_imagefilter.py deleted file mode 100644 index f7edb409a..000000000 --- a/Tests/test_imagefilter.py +++ /dev/null @@ -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 diff --git a/Tests/test_imagemode.py b/Tests/test_imagemode.py deleted file mode 100644 index 2c5730d74..000000000 --- a/Tests/test_imagemode.py +++ /dev/null @@ -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 diff --git a/Tests/test_imagetransform.py b/Tests/test_imagetransform.py deleted file mode 100644 index f5741df32..000000000 --- a/Tests/test_imagetransform.py +++ /dev/null @@ -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