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

Method test_http_body_iterable

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

Source from the content-addressed store, hash-verified

1035 30)
1036
1037 def test_http_body_iterable(self):
1038 # Generic iterable. There is no way to determine the content
1039 # length up front. Fall back to Transfer-encoding chunked.
1040
1041 h = urllib.request.AbstractHTTPHandler()
1042 o = h.parent = MockOpener()
1043
1044 def iterable_body():
1045 yield b"one"
1046
1047 for headers in {}, {"Content-Length": 11}:
1048 req = Request("http://example.com/", iterable_body(), headers)
1049 newreq = h.do_request_(req)
1050 if not headers:
1051 self.assertEqual(newreq.get_header('Content-length'), None)
1052 self.assertEqual(newreq.get_header('Transfer-encoding'),
1053 'chunked')
1054 else:
1055 self.assertEqual(int(newreq.get_header('Content-length')), 11)
1056
1057 def test_http_body_empty_seq(self):
1058 # Zero-length iterable body should be treated like any other iterable

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