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

Method test_text_file_body

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

Source from the content-addressed store, hash-verified

2300 self.assertEqual(b'body\xc1', f.read())
2301
2302 def test_text_file_body(self):
2303 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
2304 with open(os_helper.TESTFN, "w", encoding="utf-8") as f:
2305 f.write("body")
2306 with open(os_helper.TESTFN, encoding="utf-8") as f:
2307 self.conn.request("PUT", "/url", f)
2308 message, f = self.get_headers_and_fp()
2309 self.assertEqual("text/plain", message.get_content_type())
2310 self.assertIsNone(message.get_charset())
2311 # No content-length will be determined for files; the body
2312 # will be sent using chunked transfer encoding instead.
2313 self.assertIsNone(message.get("content-length"))
2314 self.assertEqual("chunked", message.get("transfer-encoding"))
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)

Callers

nothing calls this directly

Calls 11

get_headers_and_fpMethod · 0.95
addCleanupMethod · 0.80
get_content_typeMethod · 0.80
assertIsNoneMethod · 0.80
get_charsetMethod · 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