@@ -353,69 +353,14 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
353353 client .close ()
354354
355355
356- def test_client_build_url_wraps_path_strip_runtime_errors ():
356+ def test_client_build_url_rejects_string_subclass_path_inputs ():
357357 client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
358358 try :
359359 class _BrokenPath (str ):
360- def strip (self , chars = None ): # type: ignore[override]
361- _ = chars
362- raise RuntimeError ("path strip exploded" )
360+ pass
363361
364- with pytest .raises (HyperbrowserError , match = "Failed to normalize path" ) as exc_info :
365- client ._build_url (_BrokenPath ("/session" ))
366-
367- assert isinstance (exc_info .value .original_error , RuntimeError )
368- finally :
369- client .close ()
370-
371-
372- def test_client_build_url_preserves_hyperbrowser_path_strip_errors ():
373- client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
374- try :
375- class _BrokenPath (str ):
376- def strip (self , chars = None ): # type: ignore[override]
377- _ = chars
378- raise HyperbrowserError ("custom path strip failure" )
379-
380- with pytest .raises (HyperbrowserError , match = "custom path strip failure" ) as exc_info :
381- client ._build_url (_BrokenPath ("/session" ))
382-
383- assert exc_info .value .original_error is None
384- finally :
385- client .close ()
386-
387-
388- def test_client_build_url_wraps_non_string_path_strip_results ():
389- client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
390- try :
391- class _BrokenPath (str ):
392- def strip (self , chars = None ): # type: ignore[override]
393- _ = chars
394- return object ()
395-
396- with pytest .raises (HyperbrowserError , match = "Failed to normalize path" ) as exc_info :
397- client ._build_url (_BrokenPath ("/session" ))
398-
399- assert isinstance (exc_info .value .original_error , TypeError )
400- finally :
401- client .close ()
402-
403-
404- def test_client_build_url_wraps_string_subclass_path_strip_results ():
405- client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
406- try :
407- class _BrokenPath (str ):
408- class _NormalizedPath (str ):
409- pass
410-
411- def strip (self , chars = None ): # type: ignore[override]
412- _ = chars
413- return self ._NormalizedPath ("/session" )
414-
415- with pytest .raises (HyperbrowserError , match = "Failed to normalize path" ) as exc_info :
362+ with pytest .raises (HyperbrowserError , match = "path must be a string" ):
416363 client ._build_url (_BrokenPath ("/session" ))
417-
418- assert isinstance (exc_info .value .original_error , TypeError )
419364 finally :
420365 client .close ()
421366
0 commit comments