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

Method test_text_file_body

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

Source from the content-addressed store, hash-verified

2256 self.assertEqual(b'body\xc1', f.read())
2257
2258 def test_text_file_body(self):
2259 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
2260 with open(os_helper.TESTFN, "w", encoding="utf-8") as f:
2261 f.write("body")
2262 with open(os_helper.TESTFN, encoding="utf-8") as f:
2263 self.conn.request("PUT", "/url", f)
2264 message, f = self.get_headers_and_fp()
2265 self.assertEqual("text/plain", message.get_content_type())
2266 self.assertIsNone(message.get_charset())
2267 # No content-length will be determined for files; the body
2268 # will be sent using chunked transfer encoding instead.
2269 self.assertIsNone(message.get("content-length"))
2270 self.assertEqual("chunked", message.get("transfer-encoding"))
2271 self.assertEqual(b'4\r\nbody\r\n0\r\n\r\n', f.read())
2272
2273 def test_binary_file_body(self):
2274 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