Skip to content

Commit abd4baa

Browse files
committed
Fix status related tests again
1 parent c4f2a2a commit abd4baa

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

tests/integrations/opentelemetry/test_propagator.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
22

3-
from unittest import mock
43
from unittest.mock import MagicMock
54

65
from opentelemetry.trace.propagation import get_current_span
@@ -12,8 +11,6 @@
1211
SENTRY_TRACE_KEY,
1312
)
1413
from sentry_sdk.integrations.opentelemetry.propagator import SentryPropagator
15-
from sentry_sdk.integrations.opentelemetry.span_processor import SentrySpanProcessor
16-
from sentry_sdk.tracing_utils import Baggage
1714

1815

1916
@pytest.mark.forked
@@ -23,7 +20,7 @@ def test_extract_no_context_no_sentry_trace_header():
2320
Extract should return empty context.
2421
"""
2522
carrier = None
26-
context = None
23+
context = {}
2724
getter = MagicMock()
2825
getter.get.return_value = None
2926

@@ -144,8 +141,8 @@ def test_inject_continue_trace(sentry_init, SortedBaggage):
144141
with sentry_sdk.continue_trace(incoming_headers):
145142
with sentry_sdk.start_span(name="foo") as span:
146143
SentryPropagator().inject(carrier, setter=setter)
147-
assert(carrier["sentry-trace"]) == f"{trace_id}-{span.span_id}-1"
148-
assert(carrier["baggage"]) == SortedBaggage(baggage)
144+
assert (carrier["sentry-trace"]) == f"{trace_id}-{span.span_id}-1"
145+
assert (carrier["baggage"]) == SortedBaggage(baggage)
149146

150147

151148
def test_inject_head_sdk(sentry_init, SortedBaggage):
@@ -156,7 +153,7 @@ def test_inject_head_sdk(sentry_init, SortedBaggage):
156153

157154
with sentry_sdk.start_span(name="foo") as span:
158155
SentryPropagator().inject(carrier, setter=setter)
159-
assert(carrier["sentry-trace"]) == f"{span.trace_id}-{span.span_id}-1"
160-
assert(carrier["baggage"]) == SortedBaggage(
156+
assert (carrier["sentry-trace"]) == f"{span.trace_id}-{span.span_id}-1"
157+
assert (carrier["baggage"]) == SortedBaggage(
161158
f"sentry-transaction=foo,sentry-release=release,sentry-environment=production,sentry-trace_id={span.trace_id},sentry-sample_rate=1.0,sentry-sampled=true"
162159
)

tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def test_baggage_with_tracing_disabled(sentry_init, SortedBaggage):
9191
@pytest.mark.forked
9292
def test_baggage_with_tracing_enabled(sentry_init, SortedBaggage):
9393
sentry_init(traces_sample_rate=1.0, release="1.0.0", environment="dev")
94-
with start_span() as span:
95-
expected_baggage = "sentry-trace_id={},sentry-environment=dev,sentry-release=1.0.0,sentry-sample_rate=1.0,sentry-sampled={}".format(
94+
with start_span(name="foo") as span:
95+
expected_baggage = "sentry-transaction=foo,sentry-trace_id={},sentry-environment=dev,sentry-release=1.0.0,sentry-sample_rate=1.0,sentry-sampled={}".format(
9696
span.trace_id, "true" if span.sampled else "false"
9797
)
9898
assert get_baggage() == SortedBaggage(expected_baggage)

tests/tracing/test_integration_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_basic(sentry_init, capture_events, sample_rate):
3939
assert span1["status"] == "internal_error"
4040
assert span1["op"] == "foo"
4141
assert span1["description"] == "foodesc"
42-
assert "status" not in span2.get("tags", {})
42+
assert span2["tags"]["status"] == "ok"
4343
assert span2["op"] == "bar"
4444
assert span2["description"] == "bardesc"
4545
assert parent_span["transaction"] == "hi"

0 commit comments

Comments
 (0)