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

Method test_partial_readintos

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

Source from the content-addressed store, hash-verified

801 self.assertTrue(resp.closed)
802
803 def test_partial_readintos(self):
804 # if we have Content-Length, HTTPResponse knows when to close itself,
805 # the same behaviour as when we read the whole thing with read()
806 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
807 sock = FakeSocket(body)
808 resp = client.HTTPResponse(sock)
809 resp.begin()
810 b = bytearray(2)
811 n = resp.readinto(b)
812 self.assertEqual(n, 2)
813 self.assertEqual(bytes(b), b'Te')
814 self.assertFalse(resp.isclosed())
815 n = resp.readinto(b)
816 self.assertEqual(n, 2)
817 self.assertEqual(bytes(b), b'xt')
818 self.assertTrue(resp.isclosed())
819 self.assertFalse(resp.closed)
820 resp.close()
821 self.assertTrue(resp.closed)
822
823 def test_partial_reads_past_end(self):
824 # if we have Content-Length, clip reads to the end

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected