File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,39 @@ def test_client_constructor_with_config_ignores_invalid_env_headers(monkeypatch)
212212 client .close ()
213213
214214
215+ def test_async_client_constructor_with_explicit_headers_ignores_invalid_env_headers (
216+ monkeypatch ,
217+ ):
218+ monkeypatch .setenv ("HYPERBROWSER_HEADERS" , "{invalid" )
219+
220+ async def run () -> None :
221+ client = AsyncHyperbrowser (
222+ api_key = "test-key" ,
223+ headers = {"X-Team-Trace" : "constructor-value" },
224+ )
225+ try :
226+ assert (
227+ client .transport .client .headers ["X-Team-Trace" ] == "constructor-value"
228+ )
229+ finally :
230+ await client .close ()
231+
232+ asyncio .run (run ())
233+
234+
235+ def test_async_client_constructor_with_config_ignores_invalid_env_headers (monkeypatch ):
236+ monkeypatch .setenv ("HYPERBROWSER_HEADERS" , "{invalid" )
237+
238+ async def run () -> None :
239+ client = AsyncHyperbrowser (config = ClientConfig (api_key = "test-key" ))
240+ try :
241+ assert client .transport .client .headers ["x-api-key" ] == "test-key"
242+ finally :
243+ await client .close ()
244+
245+ asyncio .run (run ())
246+
247+
215248def test_client_constructor_headers_override_environment_headers (monkeypatch ):
216249 monkeypatch .setenv ("HYPERBROWSER_HEADERS" , '{"X-Team-Trace":"env-value"}' )
217250 client = Hyperbrowser (
You can’t perform that action at this time.
0 commit comments