diff --git a/skimage/io/tests/test_io.py b/skimage/io/tests/test_io.py index 6643e82e..8049860a 100644 --- a/skimage/io/tests/test_io.py +++ b/skimage/io/tests/test_io.py @@ -1,8 +1,7 @@ import os -from numpy.testing import * +from numpy.testing import assert_array_equal, raises, run_module_suite import numpy as np -from StringIO import StringIO import skimage.io as io from skimage import data_dir @@ -29,20 +28,5 @@ def test_imread_url(): assert image.shape == (512, 512) -def test_imsave_filelike(): - shape = (2, 2) - image = np.zeros(shape) - s = StringIO() - - # save to file-like object - io.imsave(s, image) - - # read from file-like object - s.seek(0) - out = io.imread(s) - assert out.shape == shape - np.testing.assert_allclose(out, image) - - if __name__ == "__main__": run_module_suite() diff --git a/skimage/io/tests/test_pil.py b/skimage/io/tests/test_pil.py index 3e2f3dde..664bcf4d 100644 --- a/skimage/io/tests/test_pil.py +++ b/skimage/io/tests/test_pil.py @@ -7,6 +7,8 @@ from tempfile import NamedTemporaryFile from skimage import data_dir from skimage.io import imread, imsave, use_plugin, reset_plugins +from skimage._shared.six.moves import StringIO + try: from PIL import Image @@ -124,5 +126,22 @@ class TestSave: x = (x * 255).astype(dtype) yield self.roundtrip, dtype, x + +@skipif(not PIL_available) +def test_imsave_filelike(): + shape = (2, 2) + image = np.zeros(shape) + s = StringIO() + + # save to file-like object + imsave(s, image) + + # read from file-like object + s.seek(0) + out = imread(s) + assert out.shape == shape + assert_allclose(out, image) + + if __name__ == "__main__": run_module_suite()