summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2012-07-02 16:38:09 -0400
committerYaroslav Halchenko <debian@onerussian.com>2012-07-02 16:38:09 -0400
commit0e3a3d96c7a8e522184c7ca0388cd9d401e902cd (patch)
tree4b89a84847bad5fb924ccc5c42689c8859a76afd /numpy/lib/tests/test_io.py
parent4df244465c3db3a8e9e624d17ed2982f595e2b8a (diff)
downloadnumpy-0e3a3d96c7a8e522184c7ca0388cd9d401e902cd.tar.gz
ENH: unittest for preceeding commit fixing #2178
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 8922070df..e9158baa8 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -167,6 +167,27 @@ class TestSavezLoad(RoundtripTest, TestCase):
if errors:
raise AssertionError(errors)
+ def test_not_closing_opened_fid(self):
+ # Test that issue #2178 is fixed:
+ # verify could seek on 'loaded' file
+
+ fd, tmp = mkstemp(suffix='.npz')
+ os.close(fd)
+ try:
+ fp = open(tmp, 'w')
+ np.savez(fp, data='LOVELY LOAD')
+ fp.close()
+
+ fp = open(tmp, 'r', 10000)
+ fp.seek(0)
+ assert_(not fp.closed)
+ _ = np.load(fp)['data']
+ assert_(not fp.closed) # must not get closed by .load(opened fp)
+ fp.seek(0)
+ assert_(not fp.closed)
+ finally:
+ os.remove(tmp)
+
class TestSaveTxt(TestCase):
def test_array(self):
a = np.array([[1, 2], [3, 4]], float)