File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,29 @@ def test_client_constructor_rejects_invalid_env_headers(monkeypatch):
151151 Hyperbrowser (api_key = "test-key" )
152152
153153
154+ def test_client_constructor_with_explicit_headers_ignores_invalid_env_headers (
155+ monkeypatch ,
156+ ):
157+ monkeypatch .setenv ("HYPERBROWSER_HEADERS" , "{invalid" )
158+ client = Hyperbrowser (
159+ api_key = "test-key" ,
160+ headers = {"X-Team-Trace" : "constructor-value" },
161+ )
162+ try :
163+ assert client .transport .client .headers ["X-Team-Trace" ] == "constructor-value"
164+ finally :
165+ client .close ()
166+
167+
168+ def test_client_constructor_with_config_ignores_invalid_env_headers (monkeypatch ):
169+ monkeypatch .setenv ("HYPERBROWSER_HEADERS" , "{invalid" )
170+ client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
171+ try :
172+ assert client .transport .client .headers ["x-api-key" ] == "test-key"
173+ finally :
174+ client .close ()
175+
176+
154177def test_client_constructor_headers_override_environment_headers (monkeypatch ):
155178 monkeypatch .setenv ("HYPERBROWSER_HEADERS" , '{"X-Team-Trace":"env-value"}' )
156179 client = Hyperbrowser (
You can’t perform that action at this time.
0 commit comments