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

Method test_binary_file_body

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

Source from the content-addressed store, hash-verified

2315 self.assertEqual(b'4\r\nbody\r\n0\r\n\r\n', f.read())
2316
2317 def test_binary_file_body(self):
2318 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
2319 with open(os_helper.TESTFN, "wb") as f:
2320 f.write(b"body\xc1")
2321 with open(os_helper.TESTFN, "rb") as f:
2322 self.conn.request("PUT", "/url", f)
2323 message, f = self.get_headers_and_fp()
2324 self.assertEqual("text/plain", message.get_content_type())
2325 self.assertIsNone(message.get_charset())
2326 self.assertEqual("chunked", message.get("Transfer-Encoding"))
2327 self.assertNotIn("Content-Length", message)
2328 self.assertEqual(b'5\r\nbody\xc1\r\n0\r\n\r\n', f.read())
2329
2330
2331class HTTPResponseTest(TestCase):

Callers

nothing calls this directly

Calls 12

get_headers_and_fpMethod · 0.95
addCleanupMethod · 0.80
get_content_typeMethod · 0.80
assertIsNoneMethod · 0.80
get_charsetMethod · 0.80
assertNotInMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
requestMethod · 0.45
assertEqualMethod · 0.45
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected