@@ -36,11 +36,10 @@ def crash():
3636 assert not events
3737
3838
39- @pytest .mark .parametrize ("propagate_scope" , (True , False ))
40- def test_propagates_scope (sentry_init , capture_events , propagate_scope ):
39+ def test_propagates_scope (sentry_init , capture_events ):
4140 sentry_init (
4241 default_integrations = False ,
43- integrations = [ThreadingIntegration (propagate_scope = propagate_scope )],
42+ integrations = [ThreadingIntegration ()],
4443 )
4544 events = capture_events ()
4645
@@ -66,17 +65,13 @@ def stage2():
6665 assert exception ["mechanism" ]["type" ] == "threading"
6766 assert not exception ["mechanism" ]["handled" ]
6867
69- if propagate_scope :
70- assert event ["tags" ]["stage1" ] == "true"
71- else :
72- assert "stage1" not in event .get ("tags" , {})
68+ assert event ["tags" ]["stage1" ] == "true"
7369
7470
75- @pytest .mark .parametrize ("propagate_scope" , (True , False ))
76- def test_propagates_threadpool_scope (sentry_init , capture_events , propagate_scope ):
71+ def test_propagates_threadpool_scope (sentry_init , capture_events ):
7772 sentry_init (
7873 traces_sample_rate = 1.0 ,
79- integrations = [ThreadingIntegration (propagate_scope = propagate_scope )],
74+ integrations = [ThreadingIntegration ()],
8075 )
8176 events = capture_events ()
8277
@@ -92,16 +87,12 @@ def double(number):
9287
9388 sentry_sdk .flush ()
9489
95- if propagate_scope :
96- assert len (events ) == 1
97- (event ,) = events
98- assert event ["spans" ][0 ]["trace_id" ] == event ["spans" ][1 ]["trace_id" ]
99- assert event ["spans" ][1 ]["trace_id" ] == event ["spans" ][2 ]["trace_id" ]
100- assert event ["spans" ][2 ]["trace_id" ] == event ["spans" ][3 ]["trace_id" ]
101- assert event ["spans" ][3 ]["trace_id" ] == event ["spans" ][0 ]["trace_id" ]
102- else :
103- (event ,) = events
104- assert len (event ["spans" ]) == 0
90+ assert len (events ) == 1
91+ (event ,) = events
92+ assert event ["spans" ][0 ]["trace_id" ] == event ["spans" ][1 ]["trace_id" ]
93+ assert event ["spans" ][1 ]["trace_id" ] == event ["spans" ][2 ]["trace_id" ]
94+ assert event ["spans" ][2 ]["trace_id" ] == event ["spans" ][3 ]["trace_id" ]
95+ assert event ["spans" ][3 ]["trace_id" ] == event ["spans" ][0 ]["trace_id" ]
10596
10697
10798def test_circular_references (sentry_init , request ):
@@ -174,27 +165,19 @@ def target():
174165 assert t .run .__qualname__ == original_run .__qualname__
175166
176167
177- @pytest .mark .parametrize (
178- "propagate_scope" ,
179- (True , False ),
180- ids = ["propagate_scope=True" , "propagate_scope=False" ],
181- )
182- def test_scope_data_not_leaked_in_threads (sentry_init , propagate_scope ):
168+ def test_scope_data_not_leaked_in_threads (sentry_init ):
183169 sentry_init (
184- integrations = [ThreadingIntegration (propagate_scope = propagate_scope )],
170+ integrations = [ThreadingIntegration ()],
185171 )
186172
187173 sentry_sdk .set_tag ("initial_tag" , "initial_value" )
188174 initial_iso_scope = sentry_sdk .get_isolation_scope ()
189175
190176 def do_some_work ():
191177 # check if we have the initial scope data propagated into the thread
192- if propagate_scope :
193- assert sentry_sdk .get_isolation_scope ()._tags == {
194- "initial_tag" : "initial_value"
195- }
196- else :
197- assert sentry_sdk .get_isolation_scope ()._tags == {}
178+ assert sentry_sdk .get_isolation_scope ()._tags == {
179+ "initial_tag" : "initial_value"
180+ }
198181
199182 # change data in isolation scope in thread
200183 sentry_sdk .set_tag ("thread_tag" , "thread_value" )
@@ -209,17 +192,14 @@ def do_some_work():
209192 }, "The isolation scope in the main thread should not be modified by the started thread."
210193
211194
212- @pytest .mark .parametrize (
213- "propagate_scope" ,
214- (True , False ),
215- ids = ["propagate_scope=True" , "propagate_scope=False" ],
216- )
217195def test_spans_from_multiple_threads (
218- sentry_init , capture_events , render_span_tree , propagate_scope
196+ sentry_init ,
197+ capture_events ,
198+ render_span_tree ,
219199):
220200 sentry_init (
221201 traces_sample_rate = 1.0 ,
222- integrations = [ThreadingIntegration (propagate_scope = propagate_scope )],
202+ integrations = [ThreadingIntegration ()],
223203 )
224204 events = capture_events ()
225205
@@ -244,31 +224,19 @@ def do_some_work(number):
244224 t .join ()
245225
246226 (event ,) = events
247- if propagate_scope :
248- assert render_span_tree (event ) == dedent (
249- """\
250- - op="outer-trx": description=null
251- - op="outer-submit-0": description="Thread: main"
252- - op="inner-run-0": description="Thread: child-0"
253- - op="outer-submit-1": description="Thread: main"
254- - op="inner-run-1": description="Thread: child-1"
255- - op="outer-submit-2": description="Thread: main"
256- - op="inner-run-2": description="Thread: child-2"
257- - op="outer-submit-3": description="Thread: main"
258- - op="inner-run-3": description="Thread: child-3"
259- - op="outer-submit-4": description="Thread: main"
260- - op="inner-run-4": description="Thread: child-4"\
261- """
262- )
263-
264- elif not propagate_scope :
265- assert render_span_tree (event ) == dedent (
266- """\
267- - op="outer-trx": description=null
268- - op="outer-submit-0": description="Thread: main"
269- - op="outer-submit-1": description="Thread: main"
270- - op="outer-submit-2": description="Thread: main"
271- - op="outer-submit-3": description="Thread: main"
272- - op="outer-submit-4": description="Thread: main"\
227+
228+ assert render_span_tree (event ) == dedent (
229+ """\
230+ - op="outer-trx": description=null
231+ - op="outer-submit-0": description="Thread: main"
232+ - op="inner-run-0": description="Thread: child-0"
233+ - op="outer-submit-1": description="Thread: main"
234+ - op="inner-run-1": description="Thread: child-1"
235+ - op="outer-submit-2": description="Thread: main"
236+ - op="inner-run-2": description="Thread: child-2"
237+ - op="outer-submit-3": description="Thread: main"
238+ - op="inner-run-3": description="Thread: child-3"
239+ - op="outer-submit-4": description="Thread: main"
240+ - op="inner-run-4": description="Thread: child-4"\
273241 """
274- )
242+ )
0 commit comments