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

Function test_python_file_implicit_mode

python/pyarrow/tests/test_io.py:322–344  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

320
321
322def test_python_file_implicit_mode(tmpdir):
323 path = os.path.join(str(tmpdir), 'foo.txt')
324 with open(path, 'wb') as f:
325 pf = pa.PythonFile(f)
326 assert pf.writable()
327 assert not pf.readable()
328 assert not pf.seekable() # PyOutputStream isn't seekable
329 f.write(b'foobar\n')
330
331 with open(path, 'rb') as f:
332 pf = pa.PythonFile(f)
333 assert pf.readable()
334 assert not pf.writable()
335 assert pf.seekable()
336 assert pf.read() == b'foobar\n'
337
338 bio = BytesIO()
339 pf = pa.PythonFile(bio)
340 assert pf.writable()
341 assert not pf.readable()
342 assert not pf.seekable()
343 pf.write(b'foobar\n')
344 assert bio.getvalue() == b'foobar\n'
345
346
347def test_python_file_writelines(tmpdir):

Callers

nothing calls this directly

Calls 5

PythonFileMethod · 0.80
writableMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected