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