mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Add os.read
This commit is contained in:
@@ -2,8 +2,15 @@ import os
|
||||
|
||||
from testutils import assert_raises
|
||||
|
||||
assert os.open('README.md', 0) > 0
|
||||
fd = os.open('README.md', 0)
|
||||
assert fd > 0
|
||||
|
||||
assert len(os.read(fd, 10)) == 10
|
||||
assert len(os.read(fd, 5)) == 5
|
||||
|
||||
assert_raises(OSError, lambda: os.read(fd + 1, 10))
|
||||
os.close(fd)
|
||||
assert_raises(OSError, lambda: os.read(fd, 10))
|
||||
|
||||
assert_raises(FileNotFoundError, lambda: os.open('DOES_NOT_EXIST', 0))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user