|
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 hyperspell.types.document_add_params import DocumentAddParams |
@@ -837,6 +839,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
837 | 839 |
|
838 | 840 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
839 | 841 |
|
| 842 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 843 | + # Test that the proxy environment variables are set correctly |
| 844 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 845 | + |
| 846 | + client = DefaultHttpxClient() |
| 847 | + |
| 848 | + mounts = tuple(client._mounts.items()) |
| 849 | + assert len(mounts) == 1 |
| 850 | + assert mounts[0][0].pattern == "https://" |
| 851 | + |
| 852 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 853 | + def test_default_client_creation(self) -> None: |
| 854 | + # Ensure that the client can be initialized without any exceptions |
| 855 | + DefaultHttpxClient( |
| 856 | + verify=True, |
| 857 | + cert=None, |
| 858 | + trust_env=True, |
| 859 | + http1=True, |
| 860 | + http2=False, |
| 861 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 862 | + ) |
| 863 | + |
840 | 864 | @pytest.mark.respx(base_url=base_url) |
841 | 865 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
842 | 866 | # Test that the default follow_redirects=True allows following redirects |
@@ -1701,6 +1725,28 @@ async def test_main() -> None: |
1701 | 1725 |
|
1702 | 1726 | time.sleep(0.1) |
1703 | 1727 |
|
| 1728 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1729 | + # Test that the proxy environment variables are set correctly |
| 1730 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1731 | + |
| 1732 | + client = DefaultAsyncHttpxClient() |
| 1733 | + |
| 1734 | + mounts = tuple(client._mounts.items()) |
| 1735 | + assert len(mounts) == 1 |
| 1736 | + assert mounts[0][0].pattern == "https://" |
| 1737 | + |
| 1738 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1739 | + async def test_default_client_creation(self) -> None: |
| 1740 | + # Ensure that the client can be initialized without any exceptions |
| 1741 | + DefaultAsyncHttpxClient( |
| 1742 | + verify=True, |
| 1743 | + cert=None, |
| 1744 | + trust_env=True, |
| 1745 | + http1=True, |
| 1746 | + http2=False, |
| 1747 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1748 | + ) |
| 1749 | + |
1704 | 1750 | @pytest.mark.respx(base_url=base_url) |
1705 | 1751 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1706 | 1752 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments