add readline to BytesIO and StringIO · RustPython/RustPython@7b83e8a · GitHub
Skip to content

Commit 7b83e8a

Browse files
committed
add readline to BytesIO and StringIO
1 parent 043413a commit 7b83e8a

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

tests/snippets/stdlib_io_bytesio.py

Lines changed: 16 additions & 0 deletions

tests/snippets/stdlib_io_stringio.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,22 @@ def test_04():
5151
assert f.seek(0) == 0
5252
assert f.read(4) == 'Test'
5353

54+
def test_05():
55+
"""
56+
Tests readline
57+
"""
58+
string = 'Test String 6\nnew line is here\nfinished'
59+
60+
f = StringIO(string)
61+
62+
assert f.readline() == 'Test String 6\n'
63+
assert f.readline() == 'new line is here\n'
64+
assert f.readline() == 'finished'
65+
assert f.readline() == ''
66+
5467
if __name__ == "__main__":
5568
test_01()
5669
test_02()
5770
test_03()
5871
test_04()
72+
test_05()

vm/src/stdlib/io.rs

Lines changed: 26 additions & 1 deletion

0 commit comments

Comments
 (0)