Skip to content

Commit 9f8f278

Browse files
committed
Fix the new tests
1 parent 9878730 commit 9f8f278

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Lib/test/test_httplib.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,11 +1615,21 @@ def _test_incomplete_read(self, read_meth):
16151615
resp.fp.read(1)
16161616
with self.assertRaises(client.IncompleteRead) as cm:
16171617
while True:
1618-
data = resp.read1()
1618+
data = read_meth()
16191619
if not data:
16201620
break
16211621
exception = cm.exception
1622-
self.assertEqual(exception.partial, b"")
1622+
# Unlike `read1` and `readline`, `read` tries to read the whole
1623+
# content during one call, so it's partial is not empty in this
1624+
# case.
1625+
# `read1` and `readline` raise `IncompleteRead` only when they
1626+
# read 0 bytes before all expected content has been read, so the
1627+
# partial is empty.
1628+
if read_meth == self.resp.read:
1629+
expected_partial = self._body[1:].encode()
1630+
else:
1631+
expected_partial = b""
1632+
self.assertEqual(exception.partial, expected_partial)
16231633
self.assertEqual(exception.expected, 1)
16241634
self.assertTrue(resp.isclosed())
16251635

0 commit comments

Comments
 (0)