File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments