@@ -36,15 +36,19 @@ async def test_default_httpx_client_factory(self):
36
36
timeout = 10 ,
37
37
sse_read_timeout = 300 , # Default value
38
38
terminate_on_close = True , # Default value
39
- httpx_client_factory = None , # Should be None when not provided
39
+ # httpx_client_factory should not be passed when not provided
40
40
)
41
41
42
42
@pytest .mark .asyncio
43
43
async def test_custom_httpx_client_factory (self ):
44
44
"""Test that custom httpx_client_factory is passed correctly."""
45
45
46
46
# Create a custom factory function
47
- def custom_factory () -> httpx .AsyncClient :
47
+ def custom_factory (
48
+ headers : dict [str , str ] | None = None ,
49
+ timeout : httpx .Timeout | None = None ,
50
+ auth : httpx .Auth | None = None ,
51
+ ) -> httpx .AsyncClient :
48
52
return httpx .AsyncClient (
49
53
verify = False , # Disable SSL verification for testing
50
54
timeout = httpx .Timeout (60.0 ),
@@ -81,7 +85,11 @@ def custom_factory() -> httpx.AsyncClient:
81
85
async def test_custom_httpx_client_factory_with_ssl_cert (self ):
82
86
"""Test custom factory with SSL certificate configuration."""
83
87
84
- def ssl_cert_factory () -> httpx .AsyncClient :
88
+ def ssl_cert_factory (
89
+ headers : dict [str , str ] | None = None ,
90
+ timeout : httpx .Timeout | None = None ,
91
+ auth : httpx .Auth | None = None ,
92
+ ) -> httpx .AsyncClient :
85
93
return httpx .AsyncClient (
86
94
verify = "/path/to/cert.pem" , # Custom SSL certificate
87
95
timeout = httpx .Timeout (120.0 ),
@@ -113,9 +121,13 @@ def ssl_cert_factory() -> httpx.AsyncClient:
113
121
async def test_custom_httpx_client_factory_with_proxy (self ):
114
122
"""Test custom factory with proxy configuration."""
115
123
116
- def proxy_factory () -> httpx .AsyncClient :
124
+ def proxy_factory (
125
+ headers : dict [str , str ] | None = None ,
126
+ timeout : httpx .Timeout | None = None ,
127
+ auth : httpx .Auth | None = None ,
128
+ ) -> httpx .AsyncClient :
117
129
return httpx .AsyncClient (
118
- proxies = "http://proxy.example.com:8080" ,
130
+ proxy = "http://proxy.example.com:8080" ,
119
131
timeout = httpx .Timeout (60.0 ),
120
132
)
121
133
@@ -144,7 +156,11 @@ def proxy_factory() -> httpx.AsyncClient:
144
156
async def test_custom_httpx_client_factory_with_retry_logic (self ):
145
157
"""Test custom factory with retry logic configuration."""
146
158
147
- def retry_factory () -> httpx .AsyncClient :
159
+ def retry_factory (
160
+ headers : dict [str , str ] | None = None ,
161
+ timeout : httpx .Timeout | None = None ,
162
+ auth : httpx .Auth | None = None ,
163
+ ) -> httpx .AsyncClient :
148
164
return httpx .AsyncClient (
149
165
timeout = httpx .Timeout (30.0 ),
150
166
# Note: httpx doesn't have built-in retry, but this shows how
@@ -194,7 +210,11 @@ def test_httpx_client_factory_type_annotation(self):
194
210
async def test_all_parameters_with_custom_factory (self ):
195
211
"""Test that all parameters work together with custom factory."""
196
212
197
- def comprehensive_factory () -> httpx .AsyncClient :
213
+ def comprehensive_factory (
214
+ headers : dict [str , str ] | None = None ,
215
+ timeout : httpx .Timeout | None = None ,
216
+ auth : httpx .Auth | None = None ,
217
+ ) -> httpx .AsyncClient :
198
218
return httpx .AsyncClient (
199
219
verify = False ,
200
220
timeout = httpx .Timeout (90.0 ),
0 commit comments