Skip to content

Commit ecce841

Browse files
committed
Merge branch 'potel-base' into potel-base-run-all-tests
2 parents 2ce3bad + 7d728f9 commit ecce841

File tree

8 files changed

+25
-30
lines changed

8 files changed

+25
-30
lines changed

tests/conftest.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,12 @@ def __ne__(self, other):
660660
return not self.__eq__(other)
661661

662662

663-
@pytest.fixture(name="SortedBaggage")
664-
def sorted_baggage_matcher():
665-
class SortedBaggage:
666-
def __init__(self, baggage):
667-
self.baggage = baggage
663+
class SortedBaggage:
664+
def __init__(self, baggage):
665+
self.baggage = baggage
668666

669-
def __eq__(self, other):
670-
return sorted(self.baggage.split(",")) == sorted(other.split(","))
671-
672-
def __ne__(self, other):
673-
return not self.__eq__(other)
667+
def __eq__(self, other):
668+
return sorted(self.baggage.split(",")) == sorted(other.split(","))
674669

675-
return SortedBaggage
670+
def __ne__(self, other):
671+
return not self.__eq__(other)

tests/integrations/httpx/test_httpx.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sentry_sdk import capture_message, start_span
1010
from sentry_sdk.consts import MATCH_ALL, SPANDATA
1111
from sentry_sdk.integrations.httpx import HttpxIntegration
12-
from tests.conftest import ApproxDict
12+
from tests.conftest import ApproxDict, SortedBaggage
1313

1414

1515
@pytest.mark.parametrize(
@@ -75,7 +75,7 @@ def test_outgoing_trace_headers(sentry_init, httpx_client, capture_envelopes):
7575
with start_span(
7676
name="/interactions/other-dogs/new-dog",
7777
op="greeting.sniff",
78-
) as span:
78+
):
7979
if asyncio.iscoroutinefunction(httpx_client.get):
8080
response = asyncio.get_event_loop().run_until_complete(
8181
httpx_client.get(url)
@@ -104,7 +104,6 @@ def test_outgoing_trace_headers_append_to_baggage(
104104
sentry_init,
105105
httpx_client,
106106
capture_envelopes,
107-
SortedBaggage, # noqa: N803
108107
):
109108
sentry_init(
110109
traces_sample_rate=1.0,
@@ -141,7 +140,7 @@ def test_outgoing_trace_headers_append_to_baggage(
141140
sampled=1,
142141
)
143142
assert response.request.headers["baggage"] == SortedBaggage(
144-
f"custom=data,sentry-trace_id={trace_id},sentry-environment=production,sentry-release=d08ebdb9309e1b004c6f52202de58a09c2268e42,sentry-transaction=/interactions/other-dogs/new-dog,sentry-sample_rate=1.0,sentry-sampled=true"
143+
f"custom=data,sentry-trace_id={trace_id},sentry-environment=production,sentry-release=d08ebdb9309e1b004c6f52202de58a09c2268e42,sentry-transaction=/interactions/other-dogs/new-dog,sentry-sample_rate=1.0,sentry-sampled=true" # noqa: E231
145144
)
146145

147146

tests/integrations/opentelemetry/test_propagator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
SENTRY_TRACE_KEY,
1212
)
1313
from sentry_sdk.integrations.opentelemetry.propagator import SentryPropagator
14+
from tests.conftest import SortedBaggage
1415

1516

1617
@pytest.mark.forked
@@ -116,7 +117,7 @@ def test_extract_context_sentry_trace_header_baggage():
116117
assert span_context.trace_id == int("1234567890abcdef1234567890abcdef", 16)
117118

118119

119-
def test_inject_continue_trace(sentry_init, SortedBaggage):
120+
def test_inject_continue_trace(sentry_init):
120121
sentry_init(traces_sample_rate=1.0)
121122

122123
carrier = {}
@@ -145,7 +146,7 @@ def test_inject_continue_trace(sentry_init, SortedBaggage):
145146
assert (carrier["baggage"]) == SortedBaggage(baggage)
146147

147148

148-
def test_inject_head_sdk(sentry_init, SortedBaggage):
149+
def test_inject_head_sdk(sentry_init):
149150
sentry_init(traces_sample_rate=1.0, release="release")
150151

151152
carrier = {}
@@ -155,5 +156,5 @@ def test_inject_head_sdk(sentry_init, SortedBaggage):
155156
SentryPropagator().inject(carrier, setter=setter)
156157
assert (carrier["sentry-trace"]) == f"{span.trace_id}-{span.span_id}-1"
157158
assert (carrier["baggage"]) == SortedBaggage(
158-
f"sentry-transaction=foo,sentry-release=release,sentry-environment=production,sentry-trace_id={span.trace_id},sentry-sample_rate=1.0,sentry-sampled=true"
159+
f"sentry-transaction=foo,sentry-release=release,sentry-environment=production,sentry-trace_id={span.trace_id},sentry-sample_rate=1.0,sentry-sampled=true" # noqa: E231
159160
)

tests/integrations/rq/test_rq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_error_has_trace_context_if_tracing_disabled(
150150
assert error_event["contexts"]["trace"]
151151

152152

153-
def test_tracing_enabled(sentry_init, capture_events, DictionaryContaining):
153+
def test_tracing_enabled(sentry_init, capture_events, DictionaryContaining): # noqa: N803
154154
sentry_init(integrations=[RqIntegration()], traces_sample_rate=1.0)
155155
events = capture_events()
156156

tests/integrations/rust_tracing/test_rust_tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def test_nested_on_new_span_on_close(sentry_init, capture_events):
121121

122122
rust_tracing.new_span(RustTracingLevel.Info, 3, index_arg=10)
123123
sentry_first_rust_span = sentry_sdk.get_current_span()
124-
rust_first_rust_span = rust_tracing.spans[3]
125124

126125
# Use a different `index_arg` value for the inner span to help
127126
# distinguish the two at the end of the test

tests/integrations/stdlib/test_httplib.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88

99
from sentry_sdk import capture_message, start_span, continue_trace, isolation_scope
1010
from sentry_sdk.consts import MATCH_ALL, SPANDATA
11-
from sentry_sdk.tracing import Transaction
1211
from sentry_sdk.integrations.stdlib import StdlibIntegration
1312

14-
from tests.conftest import ApproxDict, create_mock_http_server
13+
from tests.conftest import ApproxDict, SortedBaggage, create_mock_http_server
1514

1615
PORT = create_mock_http_server()
1716

@@ -157,7 +156,7 @@ def test_httplib_misuse(sentry_init, capture_events, request):
157156

158157

159158
def test_outgoing_trace_headers(
160-
sentry_init, capture_envelopes, capture_request_headers, SortedBaggage
159+
sentry_init, capture_envelopes, capture_request_headers
161160
):
162161
sentry_init(traces_sample_rate=1.0)
163162
envelopes = capture_envelopes()
@@ -202,7 +201,7 @@ def test_outgoing_trace_headers(
202201

203202

204203
def test_outgoing_trace_headers_head_sdk(
205-
sentry_init, monkeypatch, capture_request_headers, capture_envelopes, SortedBaggage
204+
sentry_init, monkeypatch, capture_request_headers, capture_envelopes
206205
):
207206
# make sure transaction is always sampled
208207
monkeypatch.setattr(random, "random", lambda: 0.1)
@@ -230,7 +229,7 @@ def test_outgoing_trace_headers_head_sdk(
230229
assert request_headers["sentry-trace"] == expected_sentry_trace
231230

232231
expected_outgoing_baggage = (
233-
f"sentry-trace_id={root_span.trace_id},"
232+
f"sentry-trace_id={root_span.trace_id}," # noqa: E231
234233
"sentry-environment=production,"
235234
"sentry-release=foo,"
236235
"sentry-sample_rate=0.5,"
@@ -372,4 +371,4 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):
372371

373372
span = transaction["spans"][0]
374373
assert span["op"] == "http.client"
375-
assert span["description"] == f"GET http://localhost:{PORT}/top-chasers"
374+
assert span["description"] == f"GET http://localhost:{PORT}/top-chasers" # noqa: E231

tests/test_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818

1919
from sentry_sdk.client import Client, NonRecordingClient
20+
from tests.conftest import SortedBaggage
2021

2122

2223
@pytest.mark.forked
@@ -77,7 +78,7 @@ def test_traceparent_with_tracing_disabled(sentry_init):
7778

7879

7980
@pytest.mark.forked
80-
def test_baggage_with_tracing_disabled(sentry_init, SortedBaggage):
81+
def test_baggage_with_tracing_disabled(sentry_init):
8182
sentry_init(release="1.0.0", environment="dev")
8283
propagation_context = get_isolation_scope()._propagation_context
8384
expected_baggage = (
@@ -89,7 +90,7 @@ def test_baggage_with_tracing_disabled(sentry_init, SortedBaggage):
8990

9091

9192
@pytest.mark.forked
92-
def test_baggage_with_tracing_enabled(sentry_init, SortedBaggage):
93+
def test_baggage_with_tracing_enabled(sentry_init):
9394
sentry_init(traces_sample_rate=1.0, release="1.0.0", environment="dev")
9495
with start_span(name="foo") as span:
9596
expected_baggage = "sentry-transaction=foo,sentry-trace_id={},sentry-environment=dev,sentry-release=1.0.0,sentry-sample_rate=1.0,sentry-sampled={}".format(

tests/tracing/test_integration_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from sentry_sdk.consts import SPANSTATUS
1212
from sentry_sdk.transport import Transport
13+
from tests.conftest import SortedBaggage
1314

1415

1516
@pytest.mark.parametrize("sample_rate", [0.0, 1.0])
@@ -51,7 +52,7 @@ def test_basic(sentry_init, capture_events, sample_rate):
5152

5253
@pytest.mark.parametrize("sample_rate", [0.0, 1.0])
5354
def test_continue_trace(
54-
sentry_init, capture_envelopes, sample_rate, SortedBaggage
55+
sentry_init, capture_envelopes, sample_rate
5556
): # noqa:N803
5657
"""
5758
Ensure data is actually passed along via headers, and that they are read
@@ -137,7 +138,6 @@ def test_dynamic_sampling_head_sdk_creates_dsc(
137138
capture_envelopes,
138139
sample_rate,
139140
monkeypatch,
140-
SortedBaggage, # noqa: N803
141141
):
142142
sentry_init(traces_sample_rate=sample_rate, release="foo")
143143
envelopes = capture_envelopes()

0 commit comments

Comments
 (0)