summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorPaul Anton Letnes <paul.anton.letnes@gmail.com>2011-07-28 22:50:58 +0200
committerRalf Gommers <ralf.gommers@googlemail.com>2011-07-31 13:09:38 +0200
commit72ab385d17d9067f97652aeae87a820f7de41298 (patch)
tree67415466f8bc09ce0323fd69fe692214ca09e163 /numpy/lib/tests/test_io.py
parent2acb9282bc991c4d3789bf2f7be8a2aaf1859df0 (diff)
downloadnumpy-72ab385d17d9067f97652aeae87a820f7de41298.tar.gz
ENH: let genfromtxt return empty array for empty input file instead of an error.
A warning for empty files is issued, including file name. Closes #1793.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index f9da258dc..18585375e 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -5,6 +5,7 @@ import threading
from tempfile import mkstemp, NamedTemporaryFile
import time
from datetime import datetime
+import warnings
import numpy as np
import numpy.ma as ma
@@ -637,7 +638,6 @@ class TestFromTxt(TestCase):
assert_equal(test, ctrl)
def test_skip_footer_with_invalid(self):
- import warnings
basestr = '1 1\n2 2\n3 3\n4 4\n5 \n6 \n7 \n'
warnings.filterwarnings("ignore")
# Footer too small to get rid of all invalid values
@@ -959,12 +959,12 @@ M 33 21.99
usecols=('a', 'c'), **kwargs)
assert_equal(test, ctrl)
-
def test_empty_file(self):
- "Test that an empty file raises the proper exception"
+ "Test that an empty file raises the proper warning."
+ warnings.filterwarnings("ignore", message="genfromtxt: Empty input file:")
data = StringIO()
- assert_raises(IOError, np.ndfromtxt, data)
-
+ test = np.genfromtxt(data)
+ assert_equal(test, np.array([]))
def test_fancy_dtype_alt(self):
"Check that a nested dtype isn't MIA"
@@ -1440,5 +1440,6 @@ def test_npzfile_dict():
assert_('x' in list(z.iterkeys()))
+
if __name__ == "__main__":
run_module_suite()