pitrou commented on code in PR #13144:
URL: https://github.com/apache/arrow/pull/13144#discussion_r908597511
##########
python/pyarrow/tests/test_io.py:
##########
@@ -125,6 +125,40 @@ def test_python_file_read():
pa.PythonFile(StringIO(), mode='r')
+def test_python_file_get_stream():
+ data = b'data1data2data3data4data5'
+
+ buf = BytesIO(data)
+ f = pa.PythonFile(buf, mode='r')
+
+ stream1 = f.get_stream(file_offset=0, nbytes=10)
+ stream2 = f.get_stream(file_offset=9, nbytes=16)
+
+ buf_stream2_4 = stream2.read(nbytes=4)
+ assert len(buf_stream2_4) == 4
+ assert buf_stream2_4 == b'2dat'
+ assert stream2.tell() == 4
+
+ buf_stream1_6 = stream1.read(nbytes=6)
+ assert len(buf_stream1_6) == 6
+ assert buf_stream1_6 == b'data1d'
+ assert stream1.tell() == 6
+
+ # Read to end of each stream
+ buf_stream1_4 = stream1.read(nbytes=4)
+ assert len(buf_stream1_4) == 2
+ assert buf_stream1_4 == b'a2'
Review Comment:
`buf_stream1_4` should be `b'ata2'`, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]