MCPcopy Create free account
hub / github.com/apache/arrow / test_python_file_read

Function test_python_file_read

python/pyarrow/tests/test_io.py:104–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102
103
104def test_python_file_read():
105 data = b'some sample data'
106
107 buf = BytesIO(data)
108 f = pa.PythonFile(buf, mode='r')
109
110 assert f.size() == len(data)
111
112 assert f.tell() == 0
113
114 assert f.read(4) == b'some'
115 assert f.tell() == 4
116
117 f.seek(0)
118 assert f.tell() == 0
119
120 f.seek(5)
121 assert f.tell() == 5
122
123 v = f.read(50)
124 assert v == b'sample data'
125 assert len(v) == 11
126
127 assert f.size() == len(data)
128
129 assert not f.closed
130 f.close()
131 assert f.closed
132
133 with pytest.raises(TypeError, match="binary file expected"):
134 pa.PythonFile(StringIO(), mode='r')
135
136
137@pytest.mark.parametrize("nbytes", (-1, 0, 1, 5, 100))

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
PythonFileMethod · 0.80
seekMethod · 0.80
sizeMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected