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

Method test_partial_reads

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

Source from the content-addressed store, hash-verified

817 self.assertEqual(repr(exc), '''BadStatusLine("''")''')
818
819 def test_partial_reads(self):
820 # if we have Content-Length, HTTPResponse knows when to close itself,
821 # the same behaviour as when we read the whole thing with read()
822 body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
823 sock = FakeSocket(body)
824 resp = client.HTTPResponse(sock)
825 resp.begin()
826 self.assertEqual(resp.read(2), b'Te')
827 self.assertFalse(resp.isclosed())
828 self.assertEqual(resp.read(2), b'xt')
829 self.assertTrue(resp.isclosed())
830 self.assertFalse(resp.closed)
831 resp.close()
832 self.assertTrue(resp.closed)
833
834 def test_mixed_reads(self):
835 # readline() should update the remaining length, so that read() knows

Callers

nothing calls this directly

Calls 8

beginMethod · 0.95
readMethod · 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