summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_format.py
diff options
context:
space:
mode:
authorJulian Taylor <juliantaylor108@gmail.com>2014-08-27 12:45:07 +0200
committerJulian Taylor <juliantaylor108@gmail.com>2014-08-27 12:45:07 +0200
commit0104e62e27e9fede5ffd066da16e029a3e8d99cc (patch)
tree08d2f3cbd97c900121afc62c3fd3e2928a3a22ae /numpy/lib/tests/test_format.py
parentad42ea6f614b7f9369a2a5756fea1dc66bc555d6 (diff)
parente95cf5f492bf1b181b083ff42ad451319ab23347 (diff)
downloadnumpy-0104e62e27e9fede5ffd066da16e029a3e8d99cc.tar.gz
Merge pull request #5005 from juliantaylor/use-tempdir-for-large-file
Use tempdir for large file
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r--numpy/lib/tests/test_format.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index eea6f1e5c..c09386789 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -678,28 +678,28 @@ def test_bad_header():
def test_large_file_support():
from nose import SkipTest
+ if (sys.platform == 'win32' or sys.platform == 'cygwin'):
+ raise SkipTest("Unknown if Windows has sparse filesystems")
# 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__":