From b36a759a0e89d65518531abf2736aa450abf6903 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 3 Dec 2024 10:48:21 +0100 Subject: [PATCH] Fixed pymongo tests --- tests/integrations/pymongo/test_pymongo.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/integrations/pymongo/test_pymongo.py b/tests/integrations/pymongo/test_pymongo.py index 7ebfc1159c..75e946cda8 100644 --- a/tests/integrations/pymongo/test_pymongo.py +++ b/tests/integrations/pymongo/test_pymongo.py @@ -1,6 +1,6 @@ import re -from sentry_sdk import capture_message, start_transaction +import sentry_sdk from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations.pymongo import PyMongoIntegration, _strip_pii @@ -37,7 +37,7 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii): connection = MongoClient(mongo_server.uri) - with start_transaction(): + with sentry_sdk.start_span(): list( connection["test_db"]["test_collection"].find({"foobar": 1}) ) # force query execution @@ -119,13 +119,9 @@ def test_breadcrumbs( list( connection["test_db"]["test_collection"].find({"foobar": 1}) ) # force query execution - capture_message("hi") - - if traces_sample_rate: - event = events[1] - else: - event = events[0] + sentry_sdk.capture_message("hi") + (event,) = events (crumb,) = event["breadcrumbs"]["values"] assert crumb["category"] == "query" @@ -450,7 +446,7 @@ def test_span_origin(sentry_init, capture_events, mongo_server): connection = MongoClient(mongo_server.uri) - with start_transaction(): + with sentry_sdk.start_span(): list( connection["test_db"]["test_collection"].find({"foobar": 1}) ) # force query execution