@@ -45,12 +45,6 @@ def strip(self, chars=None): # type: ignore[override]
4545 return self ._NormalizedKey ("X-Trace-Id" )
4646
4747
48- class _BrokenHeadersEnvString (str ):
49- def strip (self , chars = None ): # type: ignore[override]
50- _ = chars
51- raise RuntimeError ("headers env strip exploded" )
52-
53-
5448class _NonStringHeadersEnvStripResult (str ):
5549 def strip (self , chars = None ): # type: ignore[override]
5650 _ = chars
@@ -168,46 +162,17 @@ def test_parse_headers_env_json_rejects_non_string_input():
168162 parse_headers_env_json (123 ) # type: ignore[arg-type]
169163
170164
171- def test_parse_headers_env_json_wraps_strip_runtime_errors ():
172- with pytest .raises (
173- HyperbrowserError , match = "Failed to normalize HYPERBROWSER_HEADERS"
174- ) as exc_info :
175- parse_headers_env_json (_BrokenHeadersEnvString ('{"X-Trace-Id":"abc123"}' ))
176-
177- assert isinstance (exc_info .value .original_error , RuntimeError )
178-
179-
180- def test_parse_headers_env_json_preserves_hyperbrowser_strip_errors ():
181- class _BrokenHeadersEnvString (str ):
182- def strip (self , chars = None ): # type: ignore[override]
183- _ = chars
184- raise HyperbrowserError ("custom headers strip failure" )
185-
186- with pytest .raises (
187- HyperbrowserError , match = "custom headers strip failure"
188- ) as exc_info :
189- parse_headers_env_json (_BrokenHeadersEnvString ('{"X-Trace-Id":"abc123"}' ))
190-
191- assert exc_info .value .original_error is None
192-
193-
194- def test_parse_headers_env_json_wraps_non_string_strip_results ():
165+ def test_parse_headers_env_json_rejects_string_subclass_input_values ():
195166 with pytest .raises (
196- HyperbrowserError , match = "Failed to normalize HYPERBROWSER_HEADERS "
197- ) as exc_info :
167+ HyperbrowserError , match = "HYPERBROWSER_HEADERS must be a string "
168+ ):
198169 parse_headers_env_json (_NonStringHeadersEnvStripResult ('{"X-Trace-Id":"abc123"}' ))
199170
200- assert isinstance (exc_info .value .original_error , TypeError )
201-
202-
203- def test_parse_headers_env_json_wraps_string_subclass_strip_results ():
204171 with pytest .raises (
205- HyperbrowserError , match = "Failed to normalize HYPERBROWSER_HEADERS "
206- ) as exc_info :
172+ HyperbrowserError , match = "HYPERBROWSER_HEADERS must be a string "
173+ ):
207174 parse_headers_env_json (_StringSubclassHeadersEnvStripResult ('{"X-Trace-Id":"abc123"}' ))
208175
209- assert isinstance (exc_info .value .original_error , TypeError )
210-
211176
212177def test_parse_headers_env_json_rejects_invalid_json ():
213178 with pytest .raises (
0 commit comments