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