@@ -465,9 +465,7 @@ def test_embeddings_no_pii(
465465 assert SPANDATA .GEN_AI_EMBEDDINGS_INPUT not in span ["data" ]
466466
467467
468- def test_exception_handling (
469- reset_litellm_executor , sentry_init , capture_events , get_rate_limit_model_response
470- ):
468+ def test_exception_handling (sentry_init , capture_events ):
471469 sentry_init (
472470 integrations = [LiteLLMIntegration ()],
473471 traces_sample_rate = 1.0 ,
@@ -476,24 +474,19 @@ def test_exception_handling(
476474
477475 messages = [{"role" : "user" , "content" : "Hello!" }]
478476
479- client = OpenAI (api_key = "z" )
480-
481- model_response = get_rate_limit_model_response ()
482-
483- with mock .patch .object (
484- client .embeddings ._client ._client ,
485- "send" ,
486- return_value = model_response ,
487- ):
488- with start_transaction (name = "litellm test" ):
489- with pytest .raises (litellm .RateLimitError ):
490- litellm .completion (
491- model = "gpt-3.5-turbo" ,
492- messages = messages ,
493- client = client ,
494- )
477+ with start_transaction (name = "litellm test" ):
478+ kwargs = {
479+ "model" : "gpt-3.5-turbo" ,
480+ "messages" : messages ,
481+ }
495482
496- litellm_utils .executor .shutdown (wait = True )
483+ _input_callback (kwargs )
484+ _failure_callback (
485+ kwargs ,
486+ Exception ("API rate limit reached" ),
487+ datetime .now (),
488+ datetime .now (),
489+ )
497490
498491 # Should have error event and transaction
499492 assert len (events ) >= 1
0 commit comments