Skip to content

Commit

Permalink
Fix the new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-v committed Feb 27, 2024
1 parent 9878730 commit 9f8f278
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Lib/test/test_httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,11 +1615,21 @@ def _test_incomplete_read(self, read_meth):
resp.fp.read(1)
with self.assertRaises(client.IncompleteRead) as cm:
while True:
data = resp.read1()
data = read_meth()
if not data:
break
exception = cm.exception
self.assertEqual(exception.partial, b"")
# Unlike `read1` and `readline`, `read` tries to read the whole
# content during one call, so it's partial is not empty in this
# case.
# `read1` and `readline` raise `IncompleteRead` only when they
# read 0 bytes before all expected content has been read, so the
# partial is empty.
if read_meth == self.resp.read:
expected_partial = self._body[1:].encode()
else:
expected_partial = b""
self.assertEqual(exception.partial, expected_partial)
self.assertEqual(exception.expected, 1)
self.assertTrue(resp.isclosed())

Expand Down

0 comments on commit 9f8f278

Please sign in to comment.