|
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 |
|
@@ -818,6 +820,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
|
818 | 820 |
|
819 | 821 | assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
820 | 822 |
|
| 823 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 824 | + # Test that the proxy environment variables are set correctly |
| 825 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 826 | + |
| 827 | + client = DefaultHttpxClient() |
| 828 | + |
| 829 | + mounts = tuple(client._mounts.items()) |
| 830 | + assert len(mounts) == 1 |
| 831 | + assert mounts[0][0].pattern == "https://" |
| 832 | + |
| 833 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 834 | + def test_default_client_creation(self) -> None: |
| 835 | + # Ensure that the client can be initialized without any exceptions |
| 836 | + DefaultHttpxClient( |
| 837 | + verify=True, |
| 838 | + cert=None, |
| 839 | + trust_env=True, |
| 840 | + http1=True, |
| 841 | + http2=False, |
| 842 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 843 | + ) |
| 844 | + |
821 | 845 | @pytest.mark.respx(base_url=base_url)
|
822 | 846 | def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
823 | 847 | # Test that the default follow_redirects=True allows following redirects
|
@@ -1662,6 +1686,28 @@ async def test_main() -> None:
|
1662 | 1686 |
|
1663 | 1687 | time.sleep(0.1)
|
1664 | 1688 |
|
| 1689 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1690 | + # Test that the proxy environment variables are set correctly |
| 1691 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1692 | + |
| 1693 | + client = DefaultAsyncHttpxClient() |
| 1694 | + |
| 1695 | + mounts = tuple(client._mounts.items()) |
| 1696 | + assert len(mounts) == 1 |
| 1697 | + assert mounts[0][0].pattern == "https://" |
| 1698 | + |
| 1699 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1700 | + async def test_default_client_creation(self) -> None: |
| 1701 | + # Ensure that the client can be initialized without any exceptions |
| 1702 | + DefaultAsyncHttpxClient( |
| 1703 | + verify=True, |
| 1704 | + cert=None, |
| 1705 | + trust_env=True, |
| 1706 | + http1=True, |
| 1707 | + http2=False, |
| 1708 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1709 | + ) |
| 1710 | + |
1665 | 1711 | @pytest.mark.respx(base_url=base_url)
|
1666 | 1712 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
1667 | 1713 | # Test that the default follow_redirects=True allows following redirects
|
|
0 commit comments