add unit test for Image._repr_png_() with PIL plugin

This commit is contained in:
wilsaj
2012-08-12 18:54:43 -05:00
parent 9bd445700a
commit fabedb58ec
+15
View File
@@ -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)