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

Method test_list_body

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

Source from the content-addressed store, hash-verified

2247 return message, f
2248
2249 def test_list_body(self):
2250 # Note that no content-length is automatically calculated for
2251 # an iterable. The request will fall back to send chunked
2252 # transfer encoding.
2253 cases = (
2254 ([b'foo', b'bar'], b'3\r\nfoo\r\n3\r\nbar\r\n0\r\n\r\n'),
2255 ((b'foo', b'bar'), b'3\r\nfoo\r\n3\r\nbar\r\n0\r\n\r\n'),
2256 )
2257 for body, expected in cases:
2258 with self.subTest(body):
2259 self.conn = client.HTTPConnection('example.com')
2260 self.conn.sock = self.sock = FakeSocket('')
2261
2262 self.conn.request('PUT', '/url', body)
2263 msg, f = self.get_headers_and_fp()
2264 self.assertNotIn('Content-Type', msg)
2265 self.assertNotIn('Content-Length', msg)
2266 self.assertEqual(msg.get('Transfer-Encoding'), 'chunked')
2267 self.assertEqual(expected, f.read())
2268
2269 def test_manual_content_length(self):
2270 # Set an incorrect content-length so that we can verify that

Callers

nothing calls this directly

Calls 8

get_headers_and_fpMethod · 0.95
assertNotInMethod · 0.80
FakeSocketClass · 0.70
subTestMethod · 0.45
requestMethod · 0.45
assertEqualMethod · 0.45
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected