1
1
# coding: utf-8
2
2
import os
3
3
import json
4
+ import mock
4
5
import pytest
5
6
import subprocess
6
7
import sys
22
23
from sentry_sdk .transport import Transport
23
24
from sentry_sdk ._compat import reraise , text_type , PY2
24
25
from sentry_sdk .utils import HAS_CHAINED_EXCEPTIONS
26
+ from sentry_sdk .utils import logger
25
27
from sentry_sdk .serializer import MAX_DATABAG_BREADTH
26
28
from sentry_sdk .consts import DEFAULT_MAX_BREADCRUMBS
27
29
@@ -291,8 +293,48 @@ def e(exc):
291
293
pytest .raises (EventCapturedError , lambda : e (ValueError ()))
292
294
293
295
294
- def test_with_locals_enabled (sentry_init , capture_events ):
295
- sentry_init (with_locals = True )
296
+ def test_with_locals_deprecation_enabled (sentry_init ):
297
+ with mock .patch .object (logger , "warning" , mock .Mock ()) as fake_warning :
298
+ sentry_init (with_locals = True )
299
+
300
+ client = Hub .current .client
301
+ assert "with_locals" not in client .options
302
+ assert "include_local_variables" in client .options
303
+ assert client .options ["include_local_variables" ]
304
+
305
+ fake_warning .assert_called_once_with (
306
+ "Deprecated: The option 'with_locals' was renamed to 'include_local_variables'. Please use 'include_local_variables'. The option 'with_locals' will be removed in the future."
307
+ )
308
+
309
+
310
+ def test_with_locals_deprecation_disabled (sentry_init ):
311
+ with mock .patch .object (logger , "warning" , mock .Mock ()) as fake_warning :
312
+ sentry_init (with_locals = False )
313
+
314
+ client = Hub .current .client
315
+ assert "with_locals" not in client .options
316
+ assert "include_local_variables" in client .options
317
+ assert not client .options ["include_local_variables" ]
318
+
319
+ fake_warning .assert_called_once_with (
320
+ "Deprecated: The option 'with_locals' was renamed to 'include_local_variables'. Please use 'include_local_variables'. The option 'with_locals' will be removed in the future."
321
+ )
322
+
323
+
324
+ def test_include_local_variables_deprecation (sentry_init ):
325
+ with mock .patch .object (logger , "warning" , mock .Mock ()) as fake_warning :
326
+ sentry_init (include_local_variables = False )
327
+
328
+ client = Hub .current .client
329
+ assert "with_locals" not in client .options
330
+ assert "include_local_variables" in client .options
331
+ assert not client .options ["include_local_variables" ]
332
+
333
+ fake_warning .assert_not_called ()
334
+
335
+
336
+ def test_include_local_variables_enabled (sentry_init , capture_events ):
337
+ sentry_init (include_local_variables = True )
296
338
events = capture_events ()
297
339
try :
298
340
1 / 0
@@ -307,8 +349,8 @@ def test_with_locals_enabled(sentry_init, capture_events):
307
349
)
308
350
309
351
310
- def test_with_locals_disabled (sentry_init , capture_events ):
311
- sentry_init (with_locals = False )
352
+ def test_include_local_variables_disabled (sentry_init , capture_events ):
353
+ sentry_init (include_local_variables = False )
312
354
events = capture_events ()
313
355
try :
314
356
1 / 0
@@ -372,7 +414,7 @@ def bar():
372
414
373
415
374
416
def test_attach_stacktrace_enabled_no_locals (sentry_init , capture_events ):
375
- sentry_init (attach_stacktrace = True , with_locals = False )
417
+ sentry_init (attach_stacktrace = True , include_local_variables = False )
376
418
events = capture_events ()
377
419
378
420
def foo ():
0 commit comments