mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 01:42:45 +08:00
adds tests for new bytestream handling
This commit is contained in:
Vendored
+18
@@ -42,6 +42,8 @@ def test_extension():
|
||||
class TestSave:
|
||||
|
||||
def roundtrip(self, dtype, x):
|
||||
|
||||
# input: file name
|
||||
f = NamedTemporaryFile(suffix='.tif')
|
||||
fname = f.name
|
||||
f.close()
|
||||
@@ -49,6 +51,22 @@ class TestSave:
|
||||
y = imread(fname)
|
||||
assert_array_equal(x, y)
|
||||
|
||||
# input: open file object
|
||||
f = NamedTemporaryFile(suffix='.tif')
|
||||
imsave(f, x)
|
||||
f.seek(0)
|
||||
y = imread(f)
|
||||
assert_array_equal(x, y)
|
||||
f.close()
|
||||
|
||||
#input: byte stream
|
||||
from io import BytesIO
|
||||
b = BytesIO()
|
||||
imsave(b, x)
|
||||
b.seek(0)
|
||||
y = imread(b)
|
||||
assert_array_equal(x, y)
|
||||
|
||||
def test_imsave_roundtrip(self):
|
||||
for shape in [(10, 10), (10, 10, 3), (10, 10, 4)]:
|
||||
for dtype in (np.uint8, np.uint16, np.float32, np.int16,
|
||||
|
||||
+1
@@ -1264,6 +1264,7 @@ class TiffFile(object):
|
||||
|
||||
def close(self):
|
||||
"""Close open file handle(s)."""
|
||||
|
||||
for tif in self._files.values():
|
||||
tif._fh.close()
|
||||
self._files = {}
|
||||
|
||||
Reference in New Issue
Block a user