Skip to content

Commit 0b6c929

Browse files
committed
Refactor test_readline_incomplete_read_with_incomplete_line
1 parent 99c1aab commit 0b6c929

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_httplib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,16 +1696,16 @@ def test_readline_incomplete_read_with_incomplete_line(self):
16961696
"""
16971697
resp = self.resp
16981698
content = resp.fp.read()
1699-
# Truncate the content to the last newline.
1700-
content = content[:content.rindex(b"\n") - 1]
1699+
# Remove last newline and following bytes.
1700+
content = content.rsplit(b'\n', 1)[0]
17011701
resp.fp = io.BytesIO(content)
17021702
with self.assertRaises(client.IncompleteRead) as cm:
17031703
while True:
17041704
data = resp.readline()
17051705
if not data:
17061706
break
17071707
exception = cm.exception
1708-
self.assertEqual(exception.partial, content.split(b"\n")[-1])
1708+
self.assertEqual(exception.partial, content.rsplit(b'\n', 1)[1])
17091709
self.assertIsNone(exception.expected)
17101710
self.assertTrue(resp.isclosed())
17111711

0 commit comments

Comments
 (0)