@@ -7316,116 +7316,9 @@ async def _operation() -> str:
73167316 "runner" ,
73177317 [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
73187318)
7319- def test_retry_operation_wraps_operation_name_strip_runtime_errors (runner ):
7319+ def test_retry_operation_rejects_string_subclass_operation_names (runner ):
73207320 class _BrokenOperationName (str ):
7321- def strip (self , chars = None ): # type: ignore[override]
7322- _ = chars
7323- raise RuntimeError ("operation_name strip exploded" )
7324-
7325- with pytest .raises (
7326- HyperbrowserError , match = "Failed to normalize operation_name"
7327- ) as exc_info :
7328- runner (_BrokenOperationName ("poll operation" ))
7329-
7330- assert isinstance (exc_info .value .original_error , RuntimeError )
7331-
7332-
7333- @pytest .mark .parametrize (
7334- "runner" ,
7335- [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
7336- )
7337- def test_retry_operation_preserves_operation_name_strip_hyperbrowser_errors (runner ):
7338- class _BrokenOperationName (str ):
7339- def strip (self , chars = None ): # type: ignore[override]
7340- _ = chars
7341- raise HyperbrowserError ("custom operation_name strip failure" )
7342-
7343- with pytest .raises (
7344- HyperbrowserError , match = "custom operation_name strip failure"
7345- ) as exc_info :
7346- runner (_BrokenOperationName ("poll operation" ))
7347-
7348- assert exc_info .value .original_error is None
7349-
7350-
7351- @pytest .mark .parametrize (
7352- "runner" ,
7353- [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
7354- )
7355- def test_retry_operation_wraps_non_string_operation_name_strip_results (runner ):
7356- class _BrokenOperationName (str ):
7357- def strip (self , chars = None ): # type: ignore[override]
7358- _ = chars
7359- return object ()
7360-
7361- with pytest .raises (
7362- HyperbrowserError , match = "Failed to normalize operation_name"
7363- ) as exc_info :
7364- runner (_BrokenOperationName ("poll operation" ))
7365-
7366- assert isinstance (exc_info .value .original_error , TypeError )
7367-
7368-
7369- @pytest .mark .parametrize (
7370- "runner" ,
7371- [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
7372- )
7373- def test_retry_operation_wraps_operation_name_length_runtime_errors (runner ):
7374- class _BrokenOperationName (str ):
7375- def strip (self , chars = None ): # type: ignore[override]
7376- _ = chars
7377- return "poll operation"
7378-
7379- def __len__ (self ):
7380- raise RuntimeError ("operation_name length exploded" )
7381-
7382- with pytest .raises (
7383- HyperbrowserError , match = "Failed to validate operation_name length"
7384- ) as exc_info :
7385- runner (_BrokenOperationName ("poll operation" ))
7386-
7387- assert isinstance (exc_info .value .original_error , RuntimeError )
7388-
7389-
7390- @pytest .mark .parametrize (
7391- "runner" ,
7392- [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
7393- )
7394- def test_retry_operation_wraps_operation_name_character_validation_failures (runner ):
7395- class _BrokenOperationName (str ):
7396- def strip (self , chars = None ): # type: ignore[override]
7397- _ = chars
7398- return "poll operation"
7399-
7400- def __iter__ (self ):
7401- raise RuntimeError ("operation_name iteration exploded" )
7402-
7403- with pytest .raises (
7404- HyperbrowserError , match = "Failed to validate operation_name characters"
7405- ) as exc_info :
7406- runner (_BrokenOperationName ("poll operation" ))
7407-
7408- assert isinstance (exc_info .value .original_error , RuntimeError )
7409-
7410-
7411- @pytest .mark .parametrize (
7412- "runner" ,
7413- [_run_retry_operation_sync_with_name , _run_retry_operation_async_with_name ],
7414- )
7415- def test_retry_operation_preserves_operation_name_character_validation_hyperbrowser_errors (
7416- runner ,
7417- ):
7418- class _BrokenOperationName (str ):
7419- def strip (self , chars = None ): # type: ignore[override]
7420- _ = chars
7421- return "poll operation"
7422-
7423- def __iter__ (self ):
7424- raise HyperbrowserError ("custom operation_name character failure" )
7321+ pass
74257322
7426- with pytest .raises (
7427- HyperbrowserError , match = "custom operation_name character failure"
7428- ) as exc_info :
7323+ with pytest .raises (HyperbrowserError , match = "operation_name must be a string" ):
74297324 runner (_BrokenOperationName ("poll operation" ))
7430-
7431- assert exc_info .value .original_error is None
0 commit comments