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

Method test_http_body_pipe

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

Source from the content-addressed store, hash-verified

1013
1014 @requires_subprocess()
1015 def test_http_body_pipe(self):
1016 # A file reading from a pipe.
1017 # A pipe cannot be seek'ed. There is no way to determine the
1018 # content length up front. Thus, do_request_() should fall
1019 # back to Transfer-encoding chunked.
1020
1021 h = urllib.request.AbstractHTTPHandler()
1022 o = h.parent = MockOpener()
1023
1024 cmd = [sys.executable, "-c", r"pass"]
1025 for headers in {}, {"Content-Length": 30}:
1026 with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
1027 req = Request("http://example.com/", proc.stdout, headers)
1028 newreq = h.do_request_(req)
1029 if not headers:
1030 self.assertEqual(newreq.get_header('Content-length'), None)
1031 self.assertEqual(newreq.get_header('Transfer-encoding'),
1032 'chunked')
1033 else:
1034 self.assertEqual(int(newreq.get_header('Content-length')),
1035 30)
1036
1037 def test_http_body_iterable(self):
1038 # 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