@@ -321,6 +321,23 @@ def test_parse_extension_list_response_data_rejects_non_string_extension_keys():
321321 )
322322
323323
324+ def test_parse_extension_list_response_data_rejects_string_subclass_extension_keys ():
325+ class _Key (str ):
326+ pass
327+
328+ with pytest .raises (
329+ HyperbrowserError ,
330+ match = "Expected extension object keys to be strings at index 0" ,
331+ ):
332+ parse_extension_list_response_data (
333+ {
334+ "extensions" : [
335+ {_Key ("name" ): "invalid-key-type" },
336+ ]
337+ }
338+ )
339+
340+
324341def test_parse_extension_list_response_data_wraps_extension_value_read_failures ():
325342 class _BrokenValueLookupMapping (Mapping [str , object ]):
326343 def __iter__ (self ) -> Iterator [str ]:
@@ -367,7 +384,7 @@ def __getitem__(self, key: str) -> object:
367384 assert exc_info .value .original_error is not None
368385
369386
370- def test_parse_extension_list_response_data_falls_back_for_unreadable_value_read_keys ():
387+ def test_parse_extension_list_response_data_rejects_string_subclass_value_read_keys ():
371388 class _BrokenKey (str ):
372389 class _BrokenRenderedKey (str ):
373390 def __iter__ (self ):
@@ -389,13 +406,13 @@ def __getitem__(self, key: str) -> object:
389406
390407 with pytest .raises (
391408 HyperbrowserError ,
392- match = "Failed to read extension object value for key '<unprintable _BrokenKey>' at index 0" ,
409+ match = "Expected extension object keys to be strings at index 0" ,
393410 ) as exc_info :
394411 parse_extension_list_response_data (
395412 {"extensions" : [_BrokenValueLookupMapping ()]}
396413 )
397414
398- assert exc_info .value .original_error is not None
415+ assert exc_info .value .original_error is None
399416
400417
401418def test_parse_extension_list_response_data_preserves_hyperbrowser_value_read_errors ():
0 commit comments