1515_SENTRY_SET_USER = "sentry_sdk.set_user"
1616_AUTH0_USER = "auth0|x"
1717_SENTRY_PREFIX = "TESTPROJECT_SENTRY_"
18+ _SENTRY_SDK_INIT = "sentry_sdk.init"
19+ _SENTRY_SDK_SET_CONTEXT = "sentry_sdk.set_context"
20+ _SENTRY_SDK_IGNORE_LOGGER = "sentry_sdk.integrations.logging.ignore_logger"
1821
1922
2023def _mk_ctx (
@@ -57,9 +60,9 @@ def test_sentry_initialize_returns_true_and_calls_init_when_enabled(self, monkey
5760 monkeypatch .setenv (f"{ _SENTRY_PREFIX } ENABLED" , "true" )
5861 monkeypatch .setenv (f"{ _SENTRY_PREFIX } DSN" , _VALID_DSN )
5962 with (
60- patch ("sentry_sdk.init" ) as mock_init ,
61- patch ("sentry_sdk.set_context" ),
62- patch ("sentry_sdk.integrations.logging.ignore_logger" ),
63+ patch (_SENTRY_SDK_INIT ) as mock_init ,
64+ patch (_SENTRY_SDK_SET_CONTEXT ),
65+ patch (_SENTRY_SDK_IGNORE_LOGGER ),
6366 ):
6467 result = sentry_initialize (integrations = None , context = _mk_ctx ())
6568 assert result is True
@@ -79,9 +82,9 @@ def test_sentry_initialize_uses_context_project_name(self, monkeypatch: pytest.M
7982 monkeypatch .setenv (f"{ _SENTRY_PREFIX } DSN" , _VALID_DSN )
8083 ctx = _mk_ctx (name = "ctxproject" )
8184 with (
82- patch ("sentry_sdk.init" ) as mock_init ,
83- patch ("sentry_sdk.set_context" ),
84- patch ("sentry_sdk.integrations.logging.ignore_logger" ),
85+ patch (_SENTRY_SDK_INIT ) as mock_init ,
86+ patch (_SENTRY_SDK_SET_CONTEXT ),
87+ patch (_SENTRY_SDK_IGNORE_LOGGER ),
8588 ):
8689 result = sentry_initialize (integrations = None , context = ctx )
8790 assert result is True
@@ -93,9 +96,9 @@ def test_sentry_initialize_uses_context_environment(self, monkeypatch: pytest.Mo
9396 monkeypatch .setenv (f"{ _SENTRY_PREFIX } DSN" , _VALID_DSN )
9497 ctx = _mk_ctx (environment = "staging" )
9598 with (
96- patch ("sentry_sdk.init" ) as mock_init ,
97- patch ("sentry_sdk.set_context" ),
98- patch ("sentry_sdk.integrations.logging.ignore_logger" ),
99+ patch (_SENTRY_SDK_INIT ) as mock_init ,
100+ patch (_SENTRY_SDK_SET_CONTEXT ),
101+ patch (_SENTRY_SDK_IGNORE_LOGGER ),
99102 ):
100103 sentry_initialize (integrations = None , context = ctx )
101104 assert mock_init .call_args .kwargs ["environment" ] == "staging"
@@ -106,9 +109,9 @@ def test_sentry_initialize_uses_sentry_context_flags(self, monkeypatch: pytest.M
106109 monkeypatch .setenv (f"{ _SENTRY_PREFIX } DSN" , _VALID_DSN )
107110 ctx = _mk_ctx (is_test = True )
108111 with (
109- patch ("sentry_sdk.init" ),
110- patch ("sentry_sdk.set_context" ) as mock_set_ctx ,
111- patch ("sentry_sdk.integrations.logging.ignore_logger" ),
112+ patch (_SENTRY_SDK_INIT ),
113+ patch (_SENTRY_SDK_SET_CONTEXT ) as mock_set_ctx ,
114+ patch (_SENTRY_SDK_IGNORE_LOGGER ),
112115 ):
113116 sentry_initialize (integrations = None , context = ctx )
114117 ctx_data : dict [str , object ] = mock_set_ctx .call_args .args [1 ] # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
0 commit comments