@@ -908,17 +908,18 @@ def test_last_event_id_cleared(sentry_init):
908908
909909
910910@pytest .mark .tests_internal_exceptions
911+ @pytest .mark .parametrize ("error_cls" , [LookupError , ValueError ])
911912@pytest .mark .parametrize (
912913 "scope_manager" ,
913914 [
914915 new_scope ,
915916 use_scope ,
916917 ],
917918)
918- def test_handle_lookup_error_on_token_reset_current_scope ( scope_manager ):
919+ def test_handle_error_on_token_reset_current_scope ( error_cls , scope_manager ):
919920 with mock .patch ("sentry_sdk.scope.capture_internal_exception" ) as mock_capture :
920921 with mock .patch ("sentry_sdk.scope._current_scope" ) as mock_token_var :
921- mock_token_var .reset .side_effect = LookupError ()
922+ mock_token_var .reset .side_effect = error_cls ()
922923
923924 mock_token = mock .Mock ()
924925 mock_token_var .set .return_value = mock_token
@@ -932,27 +933,28 @@ def test_handle_lookup_error_on_token_reset_current_scope(scope_manager):
932933 pass
933934
934935 except Exception :
935- pytest .fail ("Context manager should handle LookupError gracefully" )
936+ pytest .fail (f "Context manager should handle { error_cls } gracefully" )
936937
937938 mock_capture .assert_called_once ()
938939 mock_token_var .reset .assert_called_once_with (mock_token )
939940
940941
941942@pytest .mark .tests_internal_exceptions
943+ @pytest .mark .parametrize ("error_cls" , [LookupError , ValueError ])
942944@pytest .mark .parametrize (
943945 "scope_manager" ,
944946 [
945947 isolation_scope ,
946948 use_isolation_scope ,
947949 ],
948950)
949- def test_handle_lookup_error_on_token_reset_isolation_scope ( scope_manager ):
951+ def test_handle_error_on_token_reset_isolation_scope ( error_cls , scope_manager ):
950952 with mock .patch ("sentry_sdk.scope.capture_internal_exception" ) as mock_capture :
951953 with mock .patch ("sentry_sdk.scope._current_scope" ) as mock_current_scope :
952954 with mock .patch (
953955 "sentry_sdk.scope._isolation_scope"
954956 ) as mock_isolation_scope :
955- mock_isolation_scope .reset .side_effect = LookupError ()
957+ mock_isolation_scope .reset .side_effect = error_cls ()
956958 mock_current_token = mock .Mock ()
957959 mock_current_scope .set .return_value = mock_current_token
958960
@@ -965,7 +967,7 @@ def test_handle_lookup_error_on_token_reset_isolation_scope(scope_manager):
965967 pass
966968
967969 except Exception :
968- pytest .fail ("Context manager should handle LookupError gracefully" )
970+ pytest .fail (f "Context manager should handle { error_cls } gracefully" )
969971
970972 mock_capture .assert_called_once ()
971973 mock_current_scope .reset .assert_called_once_with (mock_current_token )
0 commit comments