aboutsummaryrefslogtreecommitdiff
path: root/tests/io
diff options
context:
space:
mode:
authorPaul Sokolovsky2014-10-23 21:22:08 +0300
committerPaul Sokolovsky2014-10-23 21:43:59 +0300
commite2f8d98525ddc9ced9bbda3614de0b9b9d6bc291 (patch)
treefc998b3aca16da3129bd5079ac5fa5b7f134009b /tests/io
parent185cb0d943aa73485a83e1c146d9db899973378d (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.py10
-rw-r--r--tests/io/file_readinto_len.py.exp4
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')