diff options
author | Matthew Brett <matthew.brett@gmail.com> | 2014-07-30 19:41:22 -0700 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-08-27 12:15:46 +0200 |
commit | dcf32db293607357d0b4b152b1c630ecbccc092e (patch) | |
tree | fa9470797966311bd3e66df5fcff2005ed334149 /numpy/lib/tests/test_format.py | |
parent | 778af02eb7c1668e751f435cd2a4952a362a0433 (diff) | |
download | numpy-dcf32db293607357d0b4b152b1c630ecbccc092e.tar.gz |
BUG: avoid NamedTemporaryFile for large file test
NamedTemporaryFile files can't be reopened on Windows.
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r-- | numpy/lib/tests/test_format.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 1034b5125..9bf13bc97 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -677,27 +677,25 @@ def test_bad_header(): def test_large_file_support(): from nose import SkipTest # try creating a large sparse file - with tempfile.NamedTemporaryFile() as tf: - try: - # seek past end would work too, but linux truncate somewhat - # increases the chances that we have a sparse filesystem and can - # avoid actually writing 5GB - import subprocess as sp - sp.check_call(["truncate", "-s", "5368709120", tf.name]) - except: - raise SkipTest("Could not create 5GB large file") - # write a small array to the end - f = open(tf.name, "wb") + tf_name = os.path.join(tempdir, 'sparse_file') + try: + # seek past end would work too, but linux truncate somewhat + # increases the chances that we have a sparse filesystem and can + # avoid actually writing 5GB + import subprocess as sp + sp.check_call(["truncate", "-s", "5368709120", tf_name]) + except: + raise SkipTest("Could not create 5GB large file") + # write a small array to the end + with open(tf_name, "wb") as f: f.seek(5368709120) d = np.arange(5) np.save(f, d) - f.close() - # read it back - f = open(tf.name, "rb") + # read it back + with open(tf_name, "rb") as f: f.seek(5368709120) r = np.load(f) - f.close() - assert_array_equal(r, d) + assert_array_equal(r, d) if __name__ == "__main__": |