MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_partial_readintos_past_end

Method test_partial_readintos_past_end

Lib/test/test_httplib.py:835–848  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

833 self.assertTrue(resp.closed)
834
835 def test_partial_readintos_past_end(self):
836 # if we have Content-Length, clip readintos to the end
837 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
838 sock = FakeSocket(body)
839 resp = client.HTTPResponse(sock)
840 resp.begin()
841 b = bytearray(10)
842 n = resp.readinto(b)
843 self.assertEqual(n, 4)
844 self.assertEqual(bytes(b)[:4], b'Text')
845 self.assertTrue(resp.isclosed())
846 self.assertFalse(resp.closed)
847 resp.close()
848 self.assertTrue(resp.closed)
849
850 def test_partial_reads_no_content_length(self):
851 # when no length is present, the socket should be gracefully closed when

Callers

nothing calls this directly

Calls 8

beginMethod · 0.95
readintoMethod · 0.95
isclosedMethod · 0.95
closeMethod · 0.95
assertTrueMethod · 0.80
assertFalseMethod · 0.80
FakeSocketClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected