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

Source from the content-addressed store, hash-verified

1282
1283
1284def test_os_file_raw_fd(tmpdir):
1285 path = os.path.join(str(tmpdir), guid())
1286 binary_flag = getattr(os, "O_BINARY", 0)
1287
1288 fd = os.open(path, os.O_CREAT | os.O_WRONLY | os.O_TRUNC | binary_flag,
1289 0o666)
1290 with pa.OSFile(fd, mode='wb') as f:
1291 assert f.fileno() == fd
1292 f.write(b'foo')
1293
1294 with pytest.raises(OSError) as exc:
1295 os.fstat(fd)
1296 assert exc.value.errno == errno.EBADF
1297
1298 fd = os.open(path, os.O_RDONLY | binary_flag)
1299 with pa.OSFile(fd, mode='rb') as f:
1300 assert f.fileno() == fd
1301 assert f.read() == b'foo'
1302
1303 with pytest.raises(OSError) as exc:
1304 os.fstat(fd)
1305 assert exc.value.errno == errno.EBADF
1306
1307
1308def 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