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

Method test_proxy

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

Source from the content-addressed store, hash-verified

1445 self.assertEqual(new_req.get_method(), "HEAD")
1446
1447 def test_proxy(self):
1448 u = "proxy.example.com:3128"
1449 for d in dict(http=u), dict(HTTP=u):
1450 o = OpenerDirector()
1451 ph = urllib.request.ProxyHandler(d)
1452 o.add_handler(ph)
1453 meth_spec = [
1454 [("http_open", "return response")]
1455 ]
1456 handlers = add_ordered_mock_handlers(o, meth_spec)
1457
1458 req = Request("http://acme.example.com/")
1459 self.assertEqual(req.host, "acme.example.com")
1460 o.open(req)
1461 self.assertEqual(req.host, u)
1462 self.assertEqual([(handlers[0], "http_open")],
1463 [tup[0:2] for tup in o.calls])
1464
1465 def test_proxy_no_proxy(self):
1466 env = self.enterContext(os_helper.EnvironmentVarGuard())

Callers

nothing calls this directly

Calls 6

add_handlerMethod · 0.95
openMethod · 0.95
OpenerDirectorClass · 0.90
RequestClass · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected