diff options
| author | Paul Sokolovsky | 2014-10-23 21:22:08 +0300 |
|---|---|---|
| committer | Paul Sokolovsky | 2014-10-23 21:43:59 +0300 |
| commit | e2f8d98525ddc9ced9bbda3614de0b9b9d6bc291 (patch) | |
| tree | fc998b3aca16da3129bd5079ac5fa5b7f134009b /tests/io | |
| parent | 185cb0d943aa73485a83e1c146d9db899973378d (diff) | |
stream: Add optional 2nd "length" arg to .readinto() - extension to CPython.
While extension to file.readinto() definition of CPython, the additional arg
is similar to what in CPython available in socket.recv_into().
Diffstat (limited to 'tests/io')
| -rw-r--r-- | tests/io/file_readinto_len.py | 10 | ||||
| -rw-r--r-- | tests/io/file_readinto_len.py.exp | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/io/file_readinto_len.py b/tests/io/file_readinto_len.py new file mode 100644 index 000000000..84cc8cf5e --- /dev/null +++ b/tests/io/file_readinto_len.py @@ -0,0 +1,10 @@ +b = bytearray(30) +f = open("io/data/file1", "rb") +# 2nd arg (length to read) is extension to CPython +print(f.readinto(b, 8)) +print(b) + +b = bytearray(4) +f = open("io/data/file1", "rb") +print(f.readinto(b, 8)) +print(b) diff --git a/tests/io/file_readinto_len.py.exp b/tests/io/file_readinto_len.py.exp new file mode 100644 index 000000000..a7877115e --- /dev/null +++ b/tests/io/file_readinto_len.py.exp @@ -0,0 +1,4 @@ +8 +bytearray(b'longer l\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +4 +bytearray(b'long') |
