Skip to content

Commit dc6660e

Browse files
committed
remove match from tests
1 parent 29e9045 commit dc6660e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

tests/integrations/rust_tracing/test_rust_tracing.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,18 @@ def test_on_new_span_without_transaction(sentry_init, reset_integrations):
162162

163163

164164
def test_on_event_exception(sentry_init, reset_integrations, capture_events):
165-
def event_type_mapping(metadata: dict) -> EventTypeMapping:
166-
match RustTracingLevel(metadata.get("level")):
167-
case RustTracingLevel.Error:
168-
return EventTypeMapping.Exc
169-
case RustTracingLevel.Warn | RustTracingLevel.Info:
170-
return EventTypeMapping.Breadcrumb
171-
case RustTracingLevel.Debug:
172-
return EventTypeMapping.Event
173-
case RustTracingLevel.Trace:
174-
return EventTypeMapping.Ignore
165+
def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping:
166+
level = RustTracingLevel(metadata.get("level"))
167+
if level == RustTracingLevel.Error:
168+
return EventTypeMapping.Exc
169+
elif level in (RustTracingLevel.Warn, RustTracingLevel.Info):
170+
return EventTypeMapping.Breadcrumb
171+
elif level == RustTracingLevel.Debug:
172+
return EventTypeMapping.Event
173+
elif level == RustTracingLevel.Trace:
174+
return EventTypeMapping.Ignore
175+
else:
176+
return EventTypeMapping.Ignore
175177

176178
rust_tracing = FakeRustTracing()
177179
integration = RustTracingIntegration(
@@ -207,7 +209,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping:
207209

208210

209211
def test_on_event_breadcrumb(sentry_init, reset_integrations, capture_events):
210-
def event_type_mapping(metadata: dict) -> EventTypeMapping:
212+
def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping:
211213
match RustTracingLevel(metadata.get("level")):
212214
case RustTracingLevel.Error:
213215
return EventTypeMapping.Exc
@@ -247,7 +249,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping:
247249

248250

249251
def test_on_event_event(sentry_init, reset_integrations, capture_events):
250-
def event_type_mapping(metadata: dict) -> EventTypeMapping:
252+
def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping:
251253
match RustTracingLevel(metadata.get("level")):
252254
case RustTracingLevel.Error:
253255
return EventTypeMapping.Exc
@@ -293,7 +295,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping:
293295

294296

295297
def test_on_event_ignored(sentry_init, reset_integrations, capture_events):
296-
def event_type_mapping(metadata: dict) -> EventTypeMapping:
298+
def event_type_mapping(metadata: dict[str, object]) -> EventTypeMapping:
297299
match RustTracingLevel(metadata.get("level")):
298300
case RustTracingLevel.Error:
299301
return EventTypeMapping.Exc
@@ -328,7 +330,7 @@ def event_type_mapping(metadata: dict) -> EventTypeMapping:
328330

329331

330332
def test_span_filter(sentry_init, reset_integrations, capture_events):
331-
def span_filter(metadata: dict) -> bool:
333+
def span_filter(metadata: dict[str, object]) -> bool:
332334
return RustTracingLevel(metadata.get("level")) in (
333335
RustTracingLevel.Error,
334336
RustTracingLevel.Warn,
@@ -385,7 +387,7 @@ def test_record(sentry_init, reset_integrations):
385387

386388

387389
def test_record_in_ignored_span(sentry_init, reset_integrations):
388-
def span_filter(metadata: dict) -> bool:
390+
def span_filter(metadata: dict[str, object]) -> bool:
389391
# Just ignore Trace
390392
return RustTracingLevel(metadata.get("level")) != RustTracingLevel.Trace
391393

0 commit comments

Comments
 (0)