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

Method test_http_body_pipe

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

Source from the content-addressed store, hash-verified

1030
1031 @requires_subprocess()
1032 def test_http_body_pipe(self):
1033 # A file reading from a pipe.
1034 # A pipe cannot be seek'ed. There is no way to determine the
1035 # content length up front. Thus, do_request_() should fall
1036 # back to Transfer-encoding chunked.
1037
1038 h = urllib.request.AbstractHTTPHandler()
1039 o = h.parent = MockOpener()
1040
1041 cmd = [sys.executable, "-c", r"pass"]
1042 for headers in {}, {"Content-Length": 30}:
1043 with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
1044 req = Request("http://example.com/", proc.stdout, headers)
1045 newreq = h.do_request_(req)
1046 if not headers:
1047 self.assertEqual(newreq.get_header('Content-length'), None)
1048 self.assertEqual(newreq.get_header('Transfer-encoding'),
1049 'chunked')
1050 else:
1051 self.assertEqual(int(newreq.get_header('Content-length')),
1052 30)
1053
1054 def test_http_body_iterable(self):
1055 # Generic iterable. There is no way to determine the content

Callers

nothing calls this directly

Calls 5

do_request_Method · 0.95
RequestClass · 0.90
MockOpenerClass · 0.85
assertEqualMethod · 0.45
get_headerMethod · 0.45

Tested by

no test coverage detected