Skip to content

Commit 56c33fb

Browse files
committed
tests: add unit test for StreamReader.readlines()
1 parent 0c2f8fe commit 56c33fb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/prc/test_stream_reader.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,42 @@ def test_streamreader_readline():
157157
assert reader.readline() == b'\x00\x00'
158158

159159

160+
def test_streamreader_readlines():
161+
# Empty stream
162+
stream = StringStream(b'')
163+
reader = StreamReader(stream, False)
164+
assert reader.readlines() == []
165+
166+
# Single line without newline
167+
stream = StringStream(b'A')
168+
reader = StreamReader(stream, False)
169+
assert reader.readlines() == [b'A']
170+
assert reader.readlines() == []
171+
172+
# Single newline
173+
stream = StringStream(b'\n')
174+
reader = StreamReader(stream, False)
175+
assert reader.readlines() == [b'\n']
176+
assert reader.readlines() == []
177+
178+
# Line with text followed by empty line
179+
stream = StringStream(b'A\n\n')
180+
reader = StreamReader(stream, False)
181+
assert reader.readlines() == [b'A\n', b'\n']
182+
assert reader.readlines() == []
183+
184+
# Multiple lines
185+
stream = StringStream(b'A\nB\nC')
186+
reader = StreamReader(stream, False)
187+
assert reader.readlines() == [b'A\n', b'B\n', b'C']
188+
assert reader.readlines() == []
189+
190+
# Preserve null byte
191+
stream = StringStream(b'\x00\x00')
192+
reader = StreamReader(stream, False)
193+
assert reader.readlines() == [b'\x00\x00']
194+
195+
160196
def test_streamreader_extract_bytes():
161197
# Empty bytes
162198
stream = StringStream(b'')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy