77from sentry_sdk .utils import has_data_collection_enabled
88
99
10- def test_kvcb_invalid_mode ():
10+ def test_kvcb_invalid_mode (sentry_init ):
1111 with pytest .raises (ValueError ):
12- sentry_sdk . init (data_collection = {"cookies" : {"mode" : "nope" }}) # type: ignore Purposely ignoring to test invalid option
12+ sentry_init (data_collection = {"cookies" : {"mode" : "nope" }}) # type: ignore Purposely ignoring to test invalid option
1313
1414
15- def test_stack_frame_variables_invalid_mode ():
15+ def test_stack_frame_variables_invalid_mode (sentry_init ):
1616 with pytest .raises (ValueError ):
17- sentry_sdk . init (data_collection = {"stack_frame_variables" : {"mode" : "nope" }})
17+ sentry_init (data_collection = {"stack_frame_variables" : {"mode" : "nope" }})
1818
1919
2020@pytest .mark .parametrize (
@@ -27,45 +27,45 @@ def test_stack_frame_variables_invalid_mode():
2727 "frame_context_lines_float" ,
2828 ],
2929)
30- def test_frame_context_lines_invalid_value (value ):
30+ def test_frame_context_lines_invalid_value (sentry_init , value ):
3131 with pytest .raises (ValueError ):
32- sentry_sdk . init (data_collection = {"frame_context_lines" : value })
32+ sentry_init (data_collection = {"frame_context_lines" : value })
3333
3434
35- def test_kvcb_from_dict_defaults_mode ():
36- sentry_sdk . init (data_collection = {"cookies" : {"mode" : "denylist" , "terms" : ["x" ]}})
35+ def test_kvcb_from_dict_defaults_mode (sentry_init ):
36+ sentry_init (data_collection = {"cookies" : {"mode" : "denylist" , "terms" : ["x" ]}})
3737 client = sentry_sdk .get_client ()
3838 assert client .options ["data_collection" ]["cookies" ] == {
3939 "mode" : "denylist" ,
4040 "terms" : ["x" ],
4141 }
4242
4343
44- def test_http_headers_collection_defaults ():
44+ def test_http_headers_collection_defaults (sentry_init ):
4545 default_terms = ["forwarded" , "-ip" , "remote-" , "via" , "-user" ]
4646
47- sentry_sdk . init (data_collection = {"http_headers" : {}}) # type: ignore Purposely ignoring to test invalid option
47+ sentry_init (data_collection = {"http_headers" : {}}) # type: ignore Purposely ignoring to test invalid option
4848 client = sentry_sdk .get_client ()
4949 assert client .options ["data_collection" ]["http_headers" ]["request" ] == {
5050 "mode" : "denylist"
5151 }
5252
53- sentry_sdk . init (data_collection = {"http_headers" : "off" }) # type: ignore Purposely ignoring to test invalid option
53+ sentry_init (data_collection = {"http_headers" : "off" }) # type: ignore Purposely ignoring to test invalid option
5454 client = sentry_sdk .get_client ()
5555 assert client .options ["data_collection" ]["http_headers" ]["request" ] == {
5656 "mode" : "denylist"
5757 }
5858
59- sentry_sdk . init ()
59+ sentry_init ()
6060 client = sentry_sdk .get_client ()
6161 assert client .options ["data_collection" ]["http_headers" ]["request" ] == {
6262 "mode" : "denylist" ,
6363 "terms" : default_terms ,
6464 }
6565
6666
67- def test_http_headers_use_default_in_setting_with_missing_config ():
68- sentry_sdk . init (
67+ def test_http_headers_use_default_in_setting_with_missing_config (sentry_init ):
68+ sentry_init (
6969 data_collection = {
7070 "http_headers" : {
7171 "request" : {"mode" : "allowlist" , "terms" : ["x-id" ]},
@@ -81,8 +81,8 @@ def test_http_headers_use_default_in_setting_with_missing_config():
8181 }
8282
8383
84- def _initialize_client_with_config (** options ):
85- sentry_sdk . init (** options )
84+ def _initialize_client_with_config (sentry_init , ** options ):
85+ sentry_init (** options )
8686 return sentry_sdk .get_client ().options ["data_collection" ]
8787
8888
@@ -323,16 +323,19 @@ def _get(dc, path):
323323 ),
324324 ],
325325)
326- def test_initialize_client_data_collection (options , expected ):
327- dc = _initialize_client_with_config (** options )
326+ def test_initialize_client_data_collection (sentry_init , options , expected ):
327+ dc = _initialize_client_with_config (sentry_init , ** options )
328328 for path , value in expected .items ():
329329 assert _get (dc , path ) == value , f"{ path } != { value !r} "
330330
331331
332- def test_initialize_client_data_collection_overrides_send_default_pii_and_warns ():
332+ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns (
333+ sentry_init ,
334+ ):
333335 with warnings .catch_warnings (record = True ) as caught :
334336 warnings .simplefilter ("always" )
335337 dc = _initialize_client_with_config (
338+ sentry_init ,
336339 send_default_pii = True ,
337340 data_collection = {"user_info" : False },
338341 )
@@ -377,8 +380,8 @@ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns(
377380 ),
378381 ],
379382)
380- def test_client_data_collection_settings (init_kwargs , expected ):
381- sentry_sdk . init (** init_kwargs )
383+ def test_client_data_collection_settings (sentry_init , init_kwargs , expected ):
384+ sentry_init (** init_kwargs )
382385 client = sentry_sdk .get_client ()
383386 for key , value in expected .items ():
384387 if key == "should_send_default_pii" :
@@ -419,13 +422,17 @@ def test_has_data_collection_enabled_gates_on_user_provided_config():
419422 ),
420423 ],
421424)
422- def test_has_data_collection_enabled_after_resolution (init_kwargs , expected ):
423- sentry_sdk .init (** init_kwargs )
425+ def test_has_data_collection_enabled_after_resolution (
426+ sentry_init , init_kwargs , expected
427+ ):
428+ sentry_init (** init_kwargs )
424429 assert has_data_collection_enabled (sentry_sdk .get_client ().options ) is expected
425430
426431
427- def test_no_data_collection_values_fall_back_to_send_default_pii_configuration ():
428- sentry_sdk .init (send_default_pii = True )
432+ def test_no_data_collection_values_fall_back_to_send_default_pii_configuration (
433+ sentry_init ,
434+ ):
435+ sentry_init (send_default_pii = True )
429436 client = sentry_sdk .get_client ()
430437 dc = client .options ["data_collection" ]
431438 assert dc ["provided_by_user" ] is False
0 commit comments