MCPcopy
hub / github.com/urllib3/urllib3 / test_io_not_autoclose_bufferedreader

Method test_io_not_autoclose_bufferedreader

test/test_response.py:1218–1233  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1216 assert n3 == 0
1217
1218 def test_io_not_autoclose_bufferedreader(self) -> None:
1219 fp = BytesIO(b"hello\nworld")
1220 resp = HTTPResponse(fp, preload_content=False, auto_close=False)
1221 reader = BufferedReader(resp)
1222 assert list(reader) == [b"hello\n", b"world"]
1223
1224 assert not reader.closed
1225 assert not resp.closed
1226 with pytest.raises(StopIteration):
1227 next(reader)
1228
1229 reader.close()
1230 assert reader.closed
1231 assert resp.closed
1232 with pytest.raises(ValueError, match="readline of closed file"):
1233 next(reader)
1234
1235 def test_io_textiowrapper(self) -> None:
1236 fp = BytesIO(b"\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f")

Callers

nothing calls this directly

Calls 2

HTTPResponseClass · 0.90
closeMethod · 0.45

Tested by

no test coverage detected