@@ -135,7 +135,7 @@ def test_task_error_reporting(sentry_init, immediate_backend, capture_events):
135135 with pytest .raises (ValueError , match = "Task failed" ):
136136 _ = result .return_value
137137
138- assert len (events ) >= 1
138+ assert len (events ) == 2
139139 transaction_event = events [- 1 ]
140140 assert transaction_event ["type" ] == "transaction"
141141
@@ -148,27 +148,6 @@ def test_task_error_reporting(sentry_init, immediate_backend, capture_events):
148148 assert queue_submit_spans [0 ]["description" ] == "failing_task"
149149
150150
151- @pytest .mark .skipif (
152- not HAS_DJANGO_TASKS ,
153- reason = "Django tasks are only available in Django 6.0+" ,
154- )
155- def test_task_span_not_created_without_integration (
156- sentry_init , capture_events , immediate_backend
157- ):
158- """Test that no span is created when DjangoIntegration is not enabled."""
159- sentry_init (traces_sample_rate = 1.0 , default_integrations = False )
160- events = capture_events ()
161-
162- with sentry_sdk .start_transaction (name = "test_transaction" ):
163- simple_task .enqueue ()
164-
165- (event ,) = events
166- queue_submit_spans = [
167- span for span in event ["spans" ] if span ["op" ] == OP .QUEUE_SUBMIT_DJANGO
168- ]
169- assert len (queue_submit_spans ) == 0
170-
171-
172151@pytest .mark .skipif (
173152 not HAS_DJANGO_TASKS ,
174153 reason = "Django tasks are only available in Django 6.0+" ,
@@ -197,32 +176,3 @@ def test_multiple_task_enqueues_create_multiple_spans(
197176 span_names = [span ["description" ] for span in queue_submit_spans ]
198177 assert span_names .count ("task_one" ) == 2
199178 assert span_names .count ("task_two" ) == 1
200-
201-
202- @pytest .mark .skipif (
203- not HAS_DJANGO_TASKS ,
204- reason = "Django tasks are only available in Django 6.0+" ,
205- )
206- def test_nested_task_enqueue_spans (sentry_init , capture_events , immediate_backend ):
207- """Test that task spans are properly nested under parent spans."""
208- sentry_init (
209- integrations = [DjangoIntegration ()],
210- traces_sample_rate = 1.0 ,
211- )
212- events = capture_events ()
213-
214- with sentry_sdk .start_transaction (name = "test_transaction" ):
215- with start_span (op = "custom.operation" , name = "parent_span" ):
216- simple_task .enqueue ()
217-
218- (event ,) = events
219-
220- custom_spans = [span for span in event ["spans" ] if span ["op" ] == "custom.operation" ]
221- queue_submit_spans = [
222- span for span in event ["spans" ] if span ["op" ] == OP .QUEUE_SUBMIT_DJANGO
223- ]
224-
225- assert len (custom_spans ) == 1
226- assert len (queue_submit_spans ) == 1
227-
228- assert queue_submit_spans [0 ]["parent_span_id" ] == custom_spans [0 ]["span_id" ]
0 commit comments