diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2014-02-09 13:17:07 +0100 |
---|---|---|
committer | Julian Taylor <juliantaylor108@gmail.com> | 2014-02-09 13:17:07 +0100 |
commit | 09d0520b58df0054880465b7ceae0e83a3b8e421 (patch) | |
tree | 7de3c4eaa6bbca3a9e11c3e59e48ab7aa24fa147 /numpy/lib/tests/test_io.py | |
parent | 6a7da266ca6a55b0439117ae654664d51ebff19e (diff) | |
parent | 8296aa0b911c036c984e23665ee0f7ddca579b91 (diff) | |
download | numpy-09d0520b58df0054880465b7ceae0e83a3b8e421.tar.gz |
Merge pull request #4273 from juliantaylor/test-file-leak
TST: clean up tempfile in test_closing_zipfile_after_load
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r-- | numpy/lib/tests/test_io.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 8995fad64..a8b578097 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -295,13 +295,14 @@ class TestSavezLoad(RoundtripTest, TestCase): # Check that zipfile owns file and can close it. # This needs to pass a file name to load for the # test. - fd, tmp = mkstemp(suffix='.npz') - os.close(fd) - np.savez(tmp, lab='place holder') - data = np.load(tmp) - fp = data.zip.fp - data.close() - assert_(fp.closed) + with tempdir() as tmpdir: + fd, tmp = mkstemp(suffix='.npz', dir=tmpdir) + os.close(fd) + np.savez(tmp, lab='place holder') + data = np.load(tmp) + fp = data.zip.fp + data.close() + assert_(fp.closed) class TestSaveTxt(TestCase): |