diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2009-05-23 18:05:12 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2009-05-23 18:05:12 +0000 |
commit | 81a26d7fea2f4bf913426ec587ed211bf7c33fe5 (patch) | |
tree | 3fa35521b525e5d194c264ae7006c5eb8f49ac28 | |
parent | 557ca1216764e3c708283cc27b1b19daf818df30 (diff) | |
download | numpy-81a26d7fea2f4bf913426ec587ed211bf7c33fe5.tar.gz |
Test fromfile when file is empty.
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 7bc9875ab..7022ef14d 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -782,7 +782,7 @@ class TestLexsort(TestCase): class TestIO(object): """Test tofile, fromfile, tostring, and fromstring""" - + def setUp(self): shape = (2,4,3) rand = np.random.random @@ -796,6 +796,18 @@ class TestIO(object): os.unlink(self.filename) #tmp_file.close() + def test_empty_files_binary(self): + f = open(self.filename, 'w') + f.close() + y = fromfile(self.filename) + assert_(y.size == 0, "Array not empty") + + def test_empty_files_text(self): + f = open(self.filename, 'w') + f.close() + y = fromfile(self.filename, sep=" ") + assert_(y.size == 0, "Array not empty") + def test_roundtrip_file(self): f = open(self.filename, 'wb') self.x.tofile(f) |