|
31 | 31 | DEFAULT_TIMEOUT,
|
32 | 32 | HTTPX_DEFAULT_TIMEOUT,
|
33 | 33 | BaseClient,
|
| 34 | + DefaultHttpxClient, |
| 35 | + DefaultAsyncHttpxClient, |
34 | 36 | make_request_options,
|
35 | 37 | )
|
36 | 38 | from browserbase.types.session_create_params import SessionCreateParams
|
@@ -832,6 +834,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
|
832 | 834 |
|
833 | 835 | assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
834 | 836 |
|
| 837 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 838 | + # Test that the proxy environment variables are set correctly |
| 839 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 840 | + |
| 841 | + client = DefaultHttpxClient() |
| 842 | + |
| 843 | + mounts = tuple(client._mounts.items()) |
| 844 | + assert len(mounts) == 1 |
| 845 | + assert mounts[0][0].pattern == "https://" |
| 846 | + |
| 847 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 848 | + def test_default_client_creation(self) -> None: |
| 849 | + # Ensure that the client can be initialized without any exceptions |
| 850 | + DefaultHttpxClient( |
| 851 | + verify=True, |
| 852 | + cert=None, |
| 853 | + trust_env=True, |
| 854 | + http1=True, |
| 855 | + http2=False, |
| 856 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 857 | + ) |
| 858 | + |
835 | 859 | @pytest.mark.respx(base_url=base_url)
|
836 | 860 | def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
837 | 861 | # Test that the default follow_redirects=True allows following redirects
|
@@ -1687,6 +1711,28 @@ async def test_main() -> None:
|
1687 | 1711 |
|
1688 | 1712 | time.sleep(0.1)
|
1689 | 1713 |
|
| 1714 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1715 | + # Test that the proxy environment variables are set correctly |
| 1716 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1717 | + |
| 1718 | + client = DefaultAsyncHttpxClient() |
| 1719 | + |
| 1720 | + mounts = tuple(client._mounts.items()) |
| 1721 | + assert len(mounts) == 1 |
| 1722 | + assert mounts[0][0].pattern == "https://" |
| 1723 | + |
| 1724 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1725 | + async def test_default_client_creation(self) -> None: |
| 1726 | + # Ensure that the client can be initialized without any exceptions |
| 1727 | + DefaultAsyncHttpxClient( |
| 1728 | + verify=True, |
| 1729 | + cert=None, |
| 1730 | + trust_env=True, |
| 1731 | + http1=True, |
| 1732 | + http2=False, |
| 1733 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1734 | + ) |
| 1735 | + |
1690 | 1736 | @pytest.mark.respx(base_url=base_url)
|
1691 | 1737 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
1692 | 1738 | # Test that the default follow_redirects=True allows following redirects
|
|
0 commit comments