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

Method test_http_body_fileobj

Lib/test/test_urllib2.py:991–1012  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

989 self.assertFalse(newreq.has_header("Transfer-encoding"))
990
991 def test_http_body_fileobj(self):
992 # A file object - chunked encoding is used
993 # unless Content Length is already set.
994 # (Note that there are some subtle differences to a regular
995 # file, that is why we are testing both cases.)
996
997 h = urllib.request.AbstractHTTPHandler()
998 o = h.parent = MockOpener()
999 file_obj = io.BytesIO()
1000
1001 req = Request("http://example.com/", file_obj, {})
1002 newreq = h.do_request_(req)
1003 self.assertEqual(newreq.get_header('Transfer-encoding'), 'chunked')
1004 self.assertFalse(newreq.has_header('Content-length'))
1005
1006 headers = {"Content-Length": 30}
1007 req = Request("http://example.com/", file_obj, headers)
1008 newreq = h.do_request_(req)
1009 self.assertEqual(int(newreq.get_header('Content-length')), 30)
1010 self.assertFalse(newreq.has_header("Transfer-encoding"))
1011
1012 file_obj.close()
1013
1014 @requires_subprocess()
1015 def test_http_body_pipe(self):

Callers

nothing calls this directly

Calls 8

do_request_Method · 0.95
closeMethod · 0.95
RequestClass · 0.90
MockOpenerClass · 0.85
assertFalseMethod · 0.80
assertEqualMethod · 0.45
get_headerMethod · 0.45
has_headerMethod · 0.45

Tested by

no test coverage detected