summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2012-07-05 09:56:26 -0400
committerYaroslav Halchenko <debian@onerussian.com>2012-07-05 09:56:26 -0400
commit81a03cff05e250fd9982042c332bd4e15e0b3962 (patch)
tree0c7dfa03e0360d99e787ecc394cb22a4b6ba2ab5 /numpy/lib/tests/test_io.py
parent153f764db0a8bb15d52c76be44058922916abef5 (diff)
downloadnumpy-81a03cff05e250fd9982042c332bd4e15e0b3962.tar.gz
ENH: added a rudimentary test for having #1517 (too many open files) fixed
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index e9158baa8..f6cc365ef 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -185,9 +185,33 @@ class TestSavezLoad(RoundtripTest, TestCase):
assert_(not fp.closed) # must not get closed by .load(opened fp)
fp.seek(0)
assert_(not fp.closed)
+
+ finally:
+ os.remove(tmp)
+
+ def test_closing_fid(self):
+ # Test that issue #1517 (too many opened files) remains closed
+ # It might be a "week" test since failed to get triggered on
+ # e.g. Debian sid of 2012 Jul 05 but was reported to
+ # trigger the failure on Ubuntu 10.04:
+ # http://projects.scipy.org/numpy/ticket/1517#comment:2
+ fd, tmp = mkstemp(suffix='.npz')
+ os.close(fd)
+
+ try:
+ fp = open(tmp, 'w')
+ np.savez(fp, data='LOVELY LOAD')
+ fp.close()
+
+ for i in range(1, 1025):
+ try:
+ np.load(tmp)["data"]
+ except Exception, e:
+ raise AssertionError("Failed to load data from a file: %s" % e)
finally:
os.remove(tmp)
+
class TestSaveTxt(TestCase):
def test_array(self):
a = np.array([[1, 2], [3, 4]], float)