MCPcopy
hub / github.com/urllib3/urllib3 / test_truncated_before_chunk

Method test_truncated_before_chunk

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

Source from the content-addressed store, hash-verified

1812 assert orig_ex.length == fp.BAD_LENGTH_LINE.encode()
1813
1814 def test_truncated_before_chunk(self) -> None:
1815 stream = [b"foooo", b"bbbbaaaaar"]
1816 fp = MockChunkedNoChunks(stream)
1817 r = httplib.HTTPResponse(MockSock) # type: ignore[arg-type]
1818 r.fp = fp # type: ignore[assignment]
1819 r.chunked = True
1820 r.chunk_left = None
1821 resp = HTTPResponse(
1822 r, preload_content=False, headers={"transfer-encoding": "chunked"}
1823 )
1824 with pytest.raises(ProtocolError) as ctx:
1825 next(resp.read_chunked())
1826
1827 assert str(ctx.value) == "Response ended prematurely"
1828
1829 def test_chunked_response_without_crlf_on_end(self) -> None:
1830 stream = [b"foo", b"bar", b"baz"]

Callers

nothing calls this directly

Calls 3

read_chunkedMethod · 0.95
HTTPResponseClass · 0.90
MockChunkedNoChunksClass · 0.85

Tested by

no test coverage detected