1616except ImportError :
1717 from django .core .urlresolvers import reverse
1818
19- from sentry_sdk import capture_message , capture_exception
19+ from sentry_sdk import capture_message , capture_exception , configure_scope
2020from sentry_sdk .integrations .django import DjangoIntegration
2121
2222from tests .integrations .django .myapp .wsgi import application
@@ -182,16 +182,13 @@ def test_sql_queries(sentry_init, capture_events, with_integration):
182182
183183 from django .db import connection
184184
185- sentry_init (
186- integrations = [DjangoIntegration ()],
187- send_default_pii = True ,
188- _experiments = {"record_sql_params" : True },
189- )
190-
191185 events = capture_events ()
192186
193187 sql = connection .cursor ()
194188
189+ with configure_scope () as scope :
190+ scope .clear_breadcrumbs ()
191+
195192 with pytest .raises (OperationalError ):
196193 # table doesn't even exist
197194 sql .execute ("""SELECT count(*) FROM people_person WHERE foo = %s""" , [123 ])
@@ -201,7 +198,7 @@ def test_sql_queries(sentry_init, capture_events, with_integration):
201198 (event ,) = events
202199
203200 if with_integration :
204- crumb = event ["breadcrumbs" ][- 1 ]
201+ crumb = event ["breadcrumbs" ]["values" ][ - 1 ]
205202
206203 assert crumb ["message" ] == "SELECT count(*) FROM people_person WHERE foo = %s"
207204 assert crumb ["data" ]["db.params" ] == [123 ]
@@ -224,6 +221,9 @@ def test_sql_dict_query_params(sentry_init, capture_events):
224221 sql = connections ["postgres" ].cursor ()
225222
226223 events = capture_events ()
224+ with configure_scope () as scope :
225+ scope .clear_breadcrumbs ()
226+
227227 with pytest .raises (ProgrammingError ):
228228 sql .execute (
229229 """SELECT count(*) FROM people_person WHERE foo = %(my_foo)s""" ,
@@ -233,7 +233,7 @@ def test_sql_dict_query_params(sentry_init, capture_events):
233233 capture_message ("HI" )
234234 (event ,) = events
235235
236- crumb = event ["breadcrumbs" ][- 1 ]
236+ crumb = event ["breadcrumbs" ]["values" ][ - 1 ]
237237 assert crumb ["message" ] == (
238238 "SELECT count(*) FROM people_person WHERE foo = %(my_foo)s"
239239 )
@@ -266,14 +266,18 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query):
266266
267267 sql = connections ["postgres" ].cursor ()
268268
269+ with configure_scope () as scope :
270+ scope .clear_breadcrumbs ()
271+
269272 events = capture_events ()
273+
270274 with pytest .raises (ProgrammingError ):
271275 sql .execute (query (psycopg2 .sql ), {"my_param" : 10 })
272276
273277 capture_message ("HI" )
274278
275279 (event ,) = events
276- crumb = event ["breadcrumbs" ][- 1 ]
280+ crumb = event ["breadcrumbs" ]["values" ][ - 1 ]
277281 assert crumb ["message" ] == ('SELECT %(my_param)s FROM "foobar"' )
278282 assert crumb ["data" ]["db.params" ] == {"my_param" : 10 }
279283
@@ -296,6 +300,9 @@ def test_sql_psycopg2_placeholders(sentry_init, capture_events):
296300 sql = connections ["postgres" ].cursor ()
297301
298302 events = capture_events ()
303+ with configure_scope () as scope :
304+ scope .clear_breadcrumbs ()
305+
299306 with pytest .raises (DataError ):
300307 names = ["foo" , "bar" ]
301308 identifiers = [psycopg2 .sql .Identifier (name ) for name in names ]
@@ -313,10 +320,10 @@ def test_sql_psycopg2_placeholders(sentry_init, capture_events):
313320 capture_message ("HI" )
314321
315322 (event ,) = events
316- for crumb in event ["breadcrumbs" ]:
323+ for crumb in event ["breadcrumbs" ][ "values" ] :
317324 del crumb ["timestamp" ]
318325
319- assert event ["breadcrumbs" ][- 2 :] == [
326+ assert event ["breadcrumbs" ]["values" ][ - 2 :] == [
320327 {
321328 "category" : "query" ,
322329 "data" : {"db.paramstyle" : "format" },
0 commit comments