|
32 | 32 | DEFAULT_TIMEOUT, |
33 | 33 | HTTPX_DEFAULT_TIMEOUT, |
34 | 34 | BaseClient, |
| 35 | + DefaultHttpxClient, |
| 36 | + DefaultAsyncHttpxClient, |
35 | 37 | make_request_options, |
36 | 38 | ) |
37 | 39 | from writerai.types.chat_chat_params import ChatChatParamsNonStreaming |
@@ -860,6 +862,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
860 | 862 |
|
861 | 863 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
862 | 864 |
|
| 865 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 866 | + # Test that the proxy environment variables are set correctly |
| 867 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 868 | + |
| 869 | + client = DefaultHttpxClient() |
| 870 | + |
| 871 | + mounts = tuple(client._mounts.items()) |
| 872 | + assert len(mounts) == 1 |
| 873 | + assert mounts[0][0].pattern == "https://" |
| 874 | + |
| 875 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 876 | + def test_default_client_creation(self) -> None: |
| 877 | + # Ensure that the client can be initialized without any exceptions |
| 878 | + DefaultHttpxClient( |
| 879 | + verify=True, |
| 880 | + cert=None, |
| 881 | + trust_env=True, |
| 882 | + http1=True, |
| 883 | + http2=False, |
| 884 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 885 | + ) |
| 886 | + |
863 | 887 | @pytest.mark.respx(base_url=base_url) |
864 | 888 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
865 | 889 | # Test that the default follow_redirects=True allows following redirects |
@@ -1755,6 +1779,28 @@ async def test_main() -> None: |
1755 | 1779 |
|
1756 | 1780 | time.sleep(0.1) |
1757 | 1781 |
|
| 1782 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1783 | + # Test that the proxy environment variables are set correctly |
| 1784 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1785 | + |
| 1786 | + client = DefaultAsyncHttpxClient() |
| 1787 | + |
| 1788 | + mounts = tuple(client._mounts.items()) |
| 1789 | + assert len(mounts) == 1 |
| 1790 | + assert mounts[0][0].pattern == "https://" |
| 1791 | + |
| 1792 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1793 | + async def test_default_client_creation(self) -> None: |
| 1794 | + # Ensure that the client can be initialized without any exceptions |
| 1795 | + DefaultAsyncHttpxClient( |
| 1796 | + verify=True, |
| 1797 | + cert=None, |
| 1798 | + trust_env=True, |
| 1799 | + http1=True, |
| 1800 | + http2=False, |
| 1801 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1802 | + ) |
| 1803 | + |
1758 | 1804 | @pytest.mark.respx(base_url=base_url) |
1759 | 1805 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1760 | 1806 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments