From fdd6bf9e069a012eb446dba14c228e414cb44213 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Mon, 8 Jun 2015 22:06:24 +0200 Subject: [PATCH] tests/test_gamera: add test for to_pil_rgb(). --- tests/coverage.txt | 4 ++-- tests/test_gamera.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/coverage.txt b/tests/coverage.txt index 320554d..00eca7a 100644 --- a/tests/coverage.txt +++ b/tests/coverage.txt @@ -7,7 +7,7 @@ lib.cli 228 62 94 45 67% 102-119, 261-285, lib.djvu_support 257 120 89 52 50% 48-50, 85, 112, 115, 124, 144-166, 170-173, 176-178, 182-185, 189, 195-203, 206-220, 224, 226, 228, 230, 232, 238-239, 248-249, 252, 254, 257, 270-310, 313-321 lib.filetype 18 0 4 1 95% lib.fs 14 0 2 0 100% -lib.gamera_support 134 4 44 2 97% 205-207, 210 +lib.gamera_support 134 1 44 2 98% 210 lib.ipc 79 1 32 6 94% 106 lib.templates 40 0 14 0 100% lib.temporary 20 0 0 0 100% @@ -19,4 +19,4 @@ lib.xmp.libxmp_backend 66 4 20 2 93% 51-54 lib.xmp.namespaces 6 0 0 0 100% lib.xmp.pyexiv2_backend 119 2 20 1 98% 124-125 --------------------------------------------------------------------- -TOTAL 1099 193 337 110 79% +TOTAL 1099 190 337 110 79% diff --git a/tests/test_gamera.py b/tests/test_gamera.py index 03fd889..b621578 100644 --- a/tests/test_gamera.py +++ b/tests/test_gamera.py @@ -17,11 +17,14 @@ from . common import ( assert_equal, + assert_images_equal, assert_is_instance, assert_is_none, fork_isolation, ) +from PIL import Image as pil + from lib import gamera_support as gamera datadir = os.path.join(os.path.dirname(__file__), 'data') @@ -78,4 +81,25 @@ def test_grey(self): for x in self._test_methods('greyscale-packbits.tiff'): yield x +class test_to_pil_rgb(): + + @fork_isolation + def _test(self, path): + path = os.path.join(datadir, path) + in_image = pil.open(path) + if in_image.mode != 'RGB': + in_image = in_image.convert('RGB') + assert_equal(in_image.mode, 'RGB') + gamera.init() + gamera_image = gamera.load_image(path) + out_image = gamera.to_pil_rgb(gamera_image) + assert_equal(out_image.mode, 'RGB') + assert_images_equal(in_image, out_image) + + def test_color(self): + self._test('ycbcr-jpeg.tiff') + + def test_grey(self): + self._test('greyscale-packbits.tiff') + # vim:ts=4 sts=4 sw=4 et