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

Method test_partial_readintos_no_content_length

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

Source from the content-addressed store, hash-verified

910 self.assertTrue(resp.closed)
911
912 def test_partial_readintos_no_content_length(self):
913 # when no length is present, the socket should be gracefully closed when
914 # all data was read
915 body = "HTTP/1.1 200 Ok\r\n\r\nText"
916 sock = FakeSocket(body)
917 resp = client.HTTPResponse(sock)
918 resp.begin()
919 b = bytearray(2)
920 n = resp.readinto(b)
921 self.assertEqual(n, 2)
922 self.assertEqual(bytes(b), b'Te')
923 self.assertFalse(resp.isclosed())
924 n = resp.readinto(b)
925 self.assertEqual(n, 2)
926 self.assertEqual(bytes(b), b'xt')
927 n = resp.readinto(b)
928 self.assertEqual(n, 0)
929 self.assertTrue(resp.isclosed())
930
931 def test_partial_reads_incomplete_body(self):
932 # if the server shuts down the connection before the whole

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected