MCPcopy
hub / github.com/urllib3/urllib3 / test_tunnel

Method test_tunnel

test/with_dummyserver/test_https.py:620–645  ·  view source on GitHub ↗

test the _tunnel behavior

(self, http_version: str)

Source from the content-addressed store, hash-verified

618 https_pool.request("GET", "/")
619
620 def test_tunnel(self, http_version: str) -> None:
621 """test the _tunnel behavior"""
622 timeout = Timeout(total=None)
623 with HTTPSConnectionPool(
624 self.host,
625 self.port,
626 timeout=timeout,
627 cert_reqs="CERT_NONE",
628 ssl_minimum_version=self.tls_version(),
629 ) as https_pool:
630 with contextlib.closing(https_pool._new_conn()) as conn:
631 if http_version == "h2":
632 with pytest.raises(NotImplementedError) as e:
633 conn.set_tunnel(self.host, self.port)
634 assert (
635 str(e.value)
636 == "HTTP/2 does not support setting up a tunnel through a proxy"
637 )
638 else:
639 conn.set_tunnel(self.host, self.port)
640 with mock.patch.object(
641 conn, "_tunnel", create=True, return_value=None
642 ) as conn_tunnel:
643 with pytest.warns(InsecureRequestWarning):
644 https_pool._make_request(conn, "GET", "/")
645 conn_tunnel.assert_called_once_with()
646
647 @requires_network()
648 def test_enhanced_timeout(self) -> None:

Callers

nothing calls this directly

Calls 6

tls_versionMethod · 0.95
TimeoutClass · 0.90
HTTPSConnectionPoolClass · 0.90
_make_requestMethod · 0.80
_new_connMethod · 0.45
set_tunnelMethod · 0.45

Tested by

no test coverage detected