Skip to content

Commit c6bf58d

Browse files
committed
Added test
1 parent 7ecf57a commit c6bf58d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ strict_optional = true
6666
warn_redundant_casts = true
6767
warn_unused_configs = true
6868
warn_unused_ignores = true
69+
exclude = ["tests/"]
6970

7071
# Relaxations for code written before mypy was introduced
7172
# Do not use wildcards in module paths, otherwise added modules will

tests/tracing/test_misc.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,36 @@ def test_transaction_not_started_warning(sentry_init):
509509
"The transaction will not be sent to Sentry. To fix, start the transaction by"
510510
"passing it to sentry_sdk.start_transaction."
511511
)
512+
513+
514+
def test_span_set_data(sentry_init, capture_events):
515+
sentry_init(traces_sample_rate=1.0)
516+
517+
events = capture_events()
518+
519+
with sentry_sdk.start_transaction(name="test-transaction"):
520+
with start_span(op="test-span") as span:
521+
span.set_data("key0", "value0")
522+
span.set_data("key1", "value1")
523+
524+
span.set_data(
525+
{
526+
"key1": "updated-value1",
527+
"key2": "value2",
528+
"key3": "value3",
529+
}
530+
)
531+
532+
span.set_data(None)
533+
534+
(event,) = events
535+
span = event["spans"][0]
536+
537+
assert span["data"] == {
538+
"key0": "value0",
539+
"key1": "updated-value1",
540+
"key2": "value2",
541+
"key3": "value3",
542+
"thread.id": mock.ANY,
543+
"thread.name": mock.ANY,
544+
}

0 commit comments

Comments
 (0)