MCPcopy Index your code
hub / github.com/python/cpython / test_partial_readintos

Method test_partial_readintos

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

Source from the content-addressed store, hash-verified

847 self.assertTrue(resp.closed)
848
849 def test_partial_readintos(self):
850 # if we have Content-Length, HTTPResponse knows when to close itself,
851 # the same behaviour as when we read the whole thing with read()
852 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
853 sock = FakeSocket(body)
854 resp = client.HTTPResponse(sock)
855 resp.begin()
856 b = bytearray(2)
857 n = resp.readinto(b)
858 self.assertEqual(n, 2)
859 self.assertEqual(bytes(b), b'Te')
860 self.assertFalse(resp.isclosed())
861 n = resp.readinto(b)
862 self.assertEqual(n, 2)
863 self.assertEqual(bytes(b), b'xt')
864 self.assertTrue(resp.isclosed())
865 self.assertFalse(resp.closed)
866 resp.close()
867 self.assertTrue(resp.closed)
868
869 def test_partial_reads_past_end(self):
870 # 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