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

Function test_os_file_raw_fd

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

Source from the content-addressed store, hash-verified

1290
1291
1292def test_os_file_raw_fd(tmpdir):
1293 path = os.path.join(str(tmpdir), guid())
1294 binary_flag = getattr(os, "O_BINARY", 0)
1295
1296 fd = os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC | binary_flag,
1297 0o666)
1298 with pa.OSFile(fd, mode='wb') as f:
1299 assert f.fileno() == fd
1300 f.write(b'foo')
1301
1302 with pytest.raises(OSError) as exc:
1303 os.fstat(fd)
1304 assert exc.value.errno == errno.EBADF
1305
1306 fd = os.open(path, os.O_RDONLY | binary_flag)
1307 with pa.OSFile(fd, mode='rb') as f:
1308 assert f.fileno() == fd
1309 assert f.read() == b'foo'
1310
1311 with pytest.raises(OSError) as exc:
1312 os.fstat(fd)
1313 assert exc.value.errno == errno.EBADF
1314
1315
1316def test_native_file_write_reject_unicode():

Callers

nothing calls this directly

Calls 5

guidFunction · 0.90
joinMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected