MCPcopy Create free account
hub / github.com/numpy/numpy / test_filelike_bad_read

Method test_filelike_bad_read

numpy/lib/tests/test_loadtxt.py:863–877  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

861 BadFileLike(), dtype=np.dtype("i"), filelike=True)
862
863 def test_filelike_bad_read(self):
864 # Can only be reached if loadtxt opens the file, so it is hard to do
865 # via the public interface (although maybe not impossible considering
866 # the current "DataClass" backing).
867
868 class BadFileLike:
869 counter = 0
870
871 def read(self, size):
872 return 1234 # not a string!
873
874 with pytest.raises(TypeError,
875 match="non-string returned while reading data"):
876 np.core._multiarray_umath._load_from_filelike(
877 BadFileLike(), dtype=np.dtype("i"), filelike=True)
878
879 def test_not_an_iter(self):
880 with pytest.raises(TypeError,

Callers

nothing calls this directly

Calls 2

BadFileLikeClass · 0.85
dtypeMethod · 0.45

Tested by

no test coverage detected