diff options
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_io.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 7ec44045f..cf55c97bf 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -3387,6 +3387,20 @@ class TestCReaderUnitTests: np.core._multiarray_umath._load_from_filelike( BadFileLike(), dtype=np.dtype("i"), filelike=True) + def test_filelike_bad_read(self): + # Can only be reached if loadtxt opens the file, so it is hard to do + # via the public interface (although maybe not impossible considering + # the current "DataClass" backing). + class BadFileLike: + counter = 0 + def read(self, size): + return 1234 # not a string! + + with pytest.raises(TypeError, + match="non-string returned while reading data"): + np.core._multiarray_umath._load_from_filelike( + BadFileLike(), dtype=np.dtype("i"), filelike=True) + def test_not_an_iter(self): with pytest.raises(TypeError, match="error reading from object, expected an iterable"): |