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

Method test_list_body

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

Source from the content-addressed store, hash-verified

2203 return message, f
2204
2205 def test_list_body(self):
2206 # Note that no content-length is automatically calculated for
2207 # an iterable. The request will fall back to send chunked
2208 # transfer encoding.
2209 cases = (
2210 ([b'foo', b'bar'], b'3\r\nfoo\r\n3\r\nbar\r\n0\r\n\r\n'),
2211 ((b'foo', b'bar'), b'3\r\nfoo\r\n3\r\nbar\r\n0\r\n\r\n'),
2212 )
2213 for body, expected in cases:
2214 with self.subTest(body):
2215 self.conn = client.HTTPConnection('example.com')
2216 self.conn.sock = self.sock = FakeSocket('')
2217
2218 self.conn.request('PUT', '/url', body)
2219 msg, f = self.get_headers_and_fp()
2220 self.assertNotIn('Content-Type', msg)
2221 self.assertNotIn('Content-Length', msg)
2222 self.assertEqual(msg.get('Transfer-Encoding'), 'chunked')
2223 self.assertEqual(expected, f.read())
2224
2225 def test_manual_content_length(self):
2226 # Set an incorrect content-length so that we can verify that

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected