MCPcopy
hub / github.com/urllib3/urllib3 / test_io_closed_consistently_by_read

Method test_io_closed_consistently_by_read

test/test_response.py:1053–1071  ·  view source on GitHub ↗
(self, sock: socket.socket)

Source from the content-addressed store, hash-verified

1051 resp3.fileno()
1052
1053 def test_io_closed_consistently_by_read(self, sock: socket.socket) -> None:
1054 try:
1055 hlr = httplib.HTTPResponse(sock)
1056 hlr.fp = BytesIO(b"foo") # type: ignore[assignment]
1057 hlr.chunked = 0 # type: ignore[assignment]
1058 hlr.length = 3
1059 with HTTPResponse(hlr, preload_content=False) as resp:
1060 assert not resp.closed
1061 assert resp._fp is not None
1062 assert not resp._fp.isclosed()
1063 assert not is_fp_closed(resp._fp)
1064 assert not resp.isclosed()
1065 resp.read()
1066 assert resp.closed
1067 assert resp._fp.isclosed()
1068 assert is_fp_closed(resp._fp)
1069 assert resp.isclosed()
1070 finally:
1071 hlr.close()
1072
1073 @pytest.mark.parametrize("read_amt", (None, 3))
1074 @pytest.mark.parametrize("length_known", (True, False))

Callers

nothing calls this directly

Calls 5

closeMethod · 0.95
HTTPResponseClass · 0.90
is_fp_closedFunction · 0.90
isclosedMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected