@@ -254,9 +254,8 @@ def test_it_removes_events(mini_sentry, relay):
254254 # send the event, the transaction should be removed.
255255 relay .send_envelope (project_id , envelope )
256256 # the event should be removed by Relay sampling
257- assert mini_sentry .captured_events .get (timeout = 2 ) == only_items ("metric_buckets" )
258- with pytest .raises (queue .Empty ):
259- mini_sentry .captured_events .get (timeout = 1 )
257+ assert mini_sentry .get_captured_event () == only_items ("metric_buckets" )
258+ assert mini_sentry .captured_events .empty ()
260259
261260 outcomes = mini_sentry .captured_outcomes .get (timeout = 2 )
262261 assert outcomes is not None
@@ -285,7 +284,7 @@ def test_it_does_not_sample_error(mini_sentry, relay):
285284 # send the event, the transaction should be removed.
286285 relay .send_envelope (project_id , envelope )
287286 # test that error is kept by Relay
288- envelope = mini_sentry .captured_events . get ( timeout = 1 )
287+ envelope = mini_sentry .get_captured_event ( )
289288 assert envelope is not None
290289 # double check that we get back our object
291290 # we put the id in extra since Relay overrides the initial event_id
@@ -325,7 +324,7 @@ def test_it_tags_error(mini_sentry, relay, expected_sampled, sample_rate):
325324 # send the event, the transaction should be removed.
326325 relay .send_envelope (project_id , envelope )
327326 # test that error is kept by Relay
328- envelope = mini_sentry .captured_events . get ( timeout = 1 )
327+ envelope = mini_sentry .get_captured_event ( )
329328 assert envelope is not None
330329 # double check that we get back our object
331330 # we put the id in extra since Relay overrides the initial event_id
@@ -426,7 +425,7 @@ def test_it_keeps_events(mini_sentry, relay):
426425 # send the event, the transaction should be removed.
427426 relay .send_envelope (project_id , envelope )
428427 # the event should be left alone by Relay sampling
429- envelope = mini_sentry .captured_events . get ( timeout = 1 )
428+ envelope = mini_sentry .get_captured_event ( )
430429 assert envelope is not None
431430 # double check that we get back our object
432431 # we put the id in extra since Relay overrides the initial event_id
@@ -491,9 +490,8 @@ def test_uses_trace_public_key(mini_sentry, relay):
491490 # send the event, the transaction should be removed.
492491 relay .send_envelope (project_id2 , envelope )
493492 # the event should be removed by Relay sampling
494- assert mini_sentry .captured_events .get (timeout = 2 ) == only_items ("metric_buckets" )
495- with pytest .raises (queue .Empty ):
496- mini_sentry .captured_events .get (timeout = 1 )
493+ assert mini_sentry .get_captured_event () == only_items ("metric_buckets" )
494+ assert mini_sentry .captured_events .empty ()
497495
498496 # and it should create an outcome
499497 outcomes = mini_sentry .captured_outcomes .get (timeout = 2 ) # Spans
@@ -514,7 +512,7 @@ def test_uses_trace_public_key(mini_sentry, relay):
514512 relay .send_envelope (project_id1 , envelope )
515513
516514 # the event should be passed along to upstream (with the transaction unchanged)
517- evt = mini_sentry .captured_events . get ( timeout = 1 ).get_transaction_event ()
515+ evt = mini_sentry .get_captured_event ( ).get_transaction_event ()
518516 assert evt is not None
519517
520518 # no outcome should be generated (since the event is passed along to the upstream)
@@ -570,11 +568,8 @@ def test_multi_item_envelope(mini_sentry, relay, rule_type, event_factory):
570568 # send the event, the transaction should be removed.
571569 relay .send_envelope (project_id , envelope )
572570 # the event should be removed by Relay sampling
573- assert mini_sentry .captured_events .get (timeout = 2 ) == only_items (
574- "metric_buckets"
575- )
576- with pytest .raises (queue .Empty ):
577- mini_sentry .captured_events .get (timeout = 1 )
571+ assert mini_sentry .get_captured_event () == only_items ("metric_buckets" )
572+ assert mini_sentry .captured_events .empty ()
578573
579574 outcomes = mini_sentry .captured_outcomes .get (timeout = 2 )
580575 assert outcomes is not None
@@ -602,7 +597,7 @@ def collect_events_batch(expected_count, timeout_per_event=0.1):
602597
603598 for _ in range (expected_count * 3 ): # Allow for some extra attempts
604599 try :
605- received_envelope = mini_sentry .captured_events . get (
600+ received_envelope = mini_sentry .get_captured_event (
606601 timeout = timeout_per_event
607602 )
608603 if (
@@ -696,8 +691,7 @@ def test_relay_chain(
696691 )
697692 relay .send_envelope (project_id , envelope )
698693
699- envelope = mini_sentry .captured_events .get (timeout = 1 )
700- envelope .get_transaction_event ()
694+ assert mini_sentry .get_captured_event ().get_transaction_event () is not None
701695
702696
703697@pytest .mark .parametrize ("mode" , ["default" , "chain" ])
@@ -892,4 +886,4 @@ def test_invalid_global_generic_filters_skip_dynamic_sampling(mini_sentry, relay
892886 envelope , _ , _ = _create_transaction_envelope (public_key , client_sample_rate = 0 )
893887
894888 relay .send_envelope (project_id , envelope )
895- assert mini_sentry .captured_events . get ( timeout = 1 )
889+ assert mini_sentry .get_captured_event ( )
0 commit comments