test the _tunnel behavior
(self, http_version: str)
| 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: |
nothing calls this directly
no test coverage detected