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:323–345  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

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