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

Function test_python_file_read

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

Source from the content-addressed store, hash-verified

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