|
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 replicate.types.prediction_create_params import PredictionCreateParams |
@@ -868,6 +870,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
868 | 870 |
|
869 | 871 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
870 | 872 |
|
| 873 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 874 | + # Test that the proxy environment variables are set correctly |
| 875 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 876 | + |
| 877 | + client = DefaultHttpxClient() |
| 878 | + |
| 879 | + mounts = tuple(client._mounts.items()) |
| 880 | + assert len(mounts) == 1 |
| 881 | + assert mounts[0][0].pattern == "https://" |
| 882 | + |
| 883 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 884 | + def test_default_client_creation(self) -> None: |
| 885 | + # Ensure that the client can be initialized without any exceptions |
| 886 | + DefaultHttpxClient( |
| 887 | + verify=True, |
| 888 | + cert=None, |
| 889 | + trust_env=True, |
| 890 | + http1=True, |
| 891 | + http2=False, |
| 892 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 893 | + ) |
| 894 | + |
871 | 895 | @pytest.mark.respx(base_url=base_url) |
872 | 896 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
873 | 897 | # Test that the default follow_redirects=True allows following redirects |
@@ -1759,6 +1783,28 @@ async def test_main() -> None: |
1759 | 1783 |
|
1760 | 1784 | time.sleep(0.1) |
1761 | 1785 |
|
| 1786 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1787 | + # Test that the proxy environment variables are set correctly |
| 1788 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1789 | + |
| 1790 | + client = DefaultAsyncHttpxClient() |
| 1791 | + |
| 1792 | + mounts = tuple(client._mounts.items()) |
| 1793 | + assert len(mounts) == 1 |
| 1794 | + assert mounts[0][0].pattern == "https://" |
| 1795 | + |
| 1796 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1797 | + async def test_default_client_creation(self) -> None: |
| 1798 | + # Ensure that the client can be initialized without any exceptions |
| 1799 | + DefaultAsyncHttpxClient( |
| 1800 | + verify=True, |
| 1801 | + cert=None, |
| 1802 | + trust_env=True, |
| 1803 | + http1=True, |
| 1804 | + http2=False, |
| 1805 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1806 | + ) |
| 1807 | + |
1762 | 1808 | @pytest.mark.respx(base_url=base_url) |
1763 | 1809 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1764 | 1810 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments