(self)
| 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()) |
nothing calls this directly
no test coverage detected