From fabedb58ec4bcdb24dd816c3a405779adff7cf22 Mon Sep 17 00:00:00 2001 From: wilsaj Date: Sun, 12 Aug 2012 18:54:43 -0500 Subject: [PATCH] add unit test for Image._repr_png_() with PIL plugin --- skimage/io/tests/test_pil.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/skimage/io/tests/test_pil.py b/skimage/io/tests/test_pil.py index e442c856..fa62e1dd 100644 --- a/skimage/io/tests/test_pil.py +++ b/skimage/io/tests/test_pil.py @@ -33,6 +33,7 @@ def setup_module(self): pass + @skipif(not PIL_available) def test_imread_flatten(): # a color image is flattened @@ -78,6 +79,20 @@ def test_imread_uint16(): assert_array_almost_equal(img, expected) +@skipif(not PIL_available) +def test_repr_png(): + img_path = os.path.join(data_dir, 'camera.png') + original_img = imread(img_path) + original_img_str = original_img._repr_png_() + + with NamedTemporaryFile(suffix='.png', mode='r+') as temp_png: + temp_png.write(original_img_str) + temp_png.seek(0) + round_trip = imread(temp_png) + + assert np.all(original_img == round_trip) + + # Big endian images not correctly loaded for PIL < 1.1.7 # Renable test when PIL 1.1.7 is more common. @skipif(True)