|
30 | 30 | DEFAULT_TIMEOUT, |
31 | 31 | HTTPX_DEFAULT_TIMEOUT, |
32 | 32 | BaseClient, |
| 33 | + DefaultHttpxClient, |
| 34 | + DefaultAsyncHttpxClient, |
33 | 35 | make_request_options, |
34 | 36 | ) |
35 | 37 |
|
@@ -833,6 +835,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
833 | 835 |
|
834 | 836 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
835 | 837 |
|
| 838 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 839 | + # Test that the proxy environment variables are set correctly |
| 840 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 841 | + |
| 842 | + client = DefaultHttpxClient() |
| 843 | + |
| 844 | + mounts = tuple(client._mounts.items()) |
| 845 | + assert len(mounts) == 1 |
| 846 | + assert mounts[0][0].pattern == "https://" |
| 847 | + |
| 848 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 849 | + def test_default_client_creation(self) -> None: |
| 850 | + # Ensure that the client can be initialized without any exceptions |
| 851 | + DefaultHttpxClient( |
| 852 | + verify=True, |
| 853 | + cert=None, |
| 854 | + trust_env=True, |
| 855 | + http1=True, |
| 856 | + http2=False, |
| 857 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 858 | + ) |
| 859 | + |
836 | 860 | @pytest.mark.respx(base_url=base_url) |
837 | 861 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
838 | 862 | # Test that the default follow_redirects=True allows following redirects |
@@ -1697,6 +1721,28 @@ async def test_main() -> None: |
1697 | 1721 |
|
1698 | 1722 | time.sleep(0.1) |
1699 | 1723 |
|
| 1724 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1725 | + # Test that the proxy environment variables are set correctly |
| 1726 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1727 | + |
| 1728 | + client = DefaultAsyncHttpxClient() |
| 1729 | + |
| 1730 | + mounts = tuple(client._mounts.items()) |
| 1731 | + assert len(mounts) == 1 |
| 1732 | + assert mounts[0][0].pattern == "https://" |
| 1733 | + |
| 1734 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1735 | + async def test_default_client_creation(self) -> None: |
| 1736 | + # Ensure that the client can be initialized without any exceptions |
| 1737 | + DefaultAsyncHttpxClient( |
| 1738 | + verify=True, |
| 1739 | + cert=None, |
| 1740 | + trust_env=True, |
| 1741 | + http1=True, |
| 1742 | + http2=False, |
| 1743 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1744 | + ) |
| 1745 | + |
1700 | 1746 | @pytest.mark.respx(base_url=base_url) |
1701 | 1747 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1702 | 1748 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments