@@ -539,41 +539,47 @@ async def dispatch_request(self):
539539
540540
541541@pytest .mark .parametrize ("endpoint" , ["/sync/thread_ids" , "/async/thread_ids" ])
542- @mock .patch ("sentry_sdk.profiler.transaction_profiler.PROFILE_MINIMUM_SAMPLES" , 0 )
543542@pytest .mark .asyncio
544- async def test_active_thread_id (sentry_init , capture_envelopes , endpoint ):
545- sentry_init (
546- traces_sample_rate = 1.0 ,
547- profiles_sample_rate = 1.0 ,
548- )
549- app = quart_app_factory ()
543+ async def test_active_thread_id (
544+ sentry_init , capture_envelopes , teardown_profiling , endpoint
545+ ):
546+ with mock .patch (
547+ "sentry_sdk.profiler.transaction_profiler.PROFILE_MINIMUM_SAMPLES" , 0
548+ ):
549+ sentry_init (
550+ traces_sample_rate = 1.0 ,
551+ profiles_sample_rate = 1.0 ,
552+ )
553+ app = quart_app_factory ()
550554
551- envelopes = capture_envelopes ()
555+ envelopes = capture_envelopes ()
552556
553- async with app .test_client () as client :
554- response = await client .get (endpoint )
555- assert response .status_code == 200
557+ async with app .test_client () as client :
558+ response = await client .get (endpoint )
559+ assert response .status_code == 200
556560
557- data = json .loads (await response .get_data (as_text = True ))
561+ data = json .loads (await response .get_data (as_text = True ))
558562
559- envelopes = [envelope for envelope in envelopes ]
560- assert len (envelopes ) == 1
563+ envelopes = [envelope for envelope in envelopes ]
564+ assert len (envelopes ) == 1
561565
562- profiles = [item for item in envelopes [0 ].items if item .type == "profile" ]
563- assert len (profiles ) == 1 , envelopes [0 ].items
566+ profiles = [item for item in envelopes [0 ].items if item .type == "profile" ]
567+ assert len (profiles ) == 1 , envelopes [0 ].items
564568
565- for item in profiles :
566- transactions = item .payload .json ["transactions" ]
567- assert len (transactions ) == 1
568- assert str (data ["active" ]) == transactions [0 ]["active_thread_id" ]
569+ for item in profiles :
570+ transactions = item .payload .json ["transactions" ]
571+ assert len (transactions ) == 1
572+ assert str (data ["active" ]) == transactions [0 ]["active_thread_id" ]
569573
570- transactions = [item for item in envelopes [0 ].items if item .type == "transaction" ]
571- assert len (transactions ) == 1
574+ transactions = [
575+ item for item in envelopes [0 ].items if item .type == "transaction"
576+ ]
577+ assert len (transactions ) == 1
572578
573- for item in transactions :
574- transaction = item .payload .json
575- trace_context = transaction ["contexts" ]["trace" ]
576- assert str (data ["active" ]) == trace_context ["data" ]["thread.id" ]
579+ for item in transactions :
580+ transaction = item .payload .json
581+ trace_context = transaction ["contexts" ]["trace" ]
582+ assert str (data ["active" ]) == trace_context ["data" ]["thread.id" ]
577583
578584
579585@pytest .mark .asyncio
0 commit comments