1010from ldclient .integrations .test_data import TestData
1111
1212import sentry_sdk
13+ from sentry_sdk .integrations import DidNotEnable
1314from sentry_sdk .integrations .launchdarkly import LaunchDarklyIntegration
1415
1516
@@ -26,10 +27,11 @@ def test_launchdarkly_integration(
2627 uninstall_integration (LaunchDarklyIntegration .identifier )
2728 if use_global_client :
2829 ldclient .set_config (config )
30+ sentry_init (integrations = [LaunchDarklyIntegration ()])
2931 client = ldclient .get ()
3032 else :
3133 client = LDClient (config = config )
32- sentry_init (integrations = [LaunchDarklyIntegration (client )])
34+ sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
3335
3436 # Set test values
3537 td .update (td .flag ("hello" ).variation_for_all (True ))
@@ -61,7 +63,7 @@ def test_launchdarkly_integration_threaded(
6163 context = Context .create ("user1" )
6264
6365 uninstall_integration (LaunchDarklyIntegration .identifier )
64- sentry_init (integrations = [LaunchDarklyIntegration (client )])
66+ sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
6567 events = capture_events ()
6668
6769 def task (flag_key ):
@@ -120,7 +122,7 @@ def test_launchdarkly_integration_asyncio(
120122 context = Context .create ("user1" )
121123
122124 uninstall_integration (LaunchDarklyIntegration .identifier )
123- sentry_init (integrations = [LaunchDarklyIntegration (client )])
125+ sentry_init (integrations = [LaunchDarklyIntegration (ld_client = client )])
124126 events = capture_events ()
125127
126128 async def task (flag_key ):
@@ -164,3 +166,23 @@ async def runner():
164166 {"flag" : "world" , "result" : False },
165167 ]
166168 }
169+
170+
171+ def test_launchdarkly_integration_did_not_enable (sentry_init , uninstall_integration ):
172+ """
173+ Setup should fail when using global client and ldclient.set_config wasn't called.
174+
175+ We're accessing ldclient internals to set up this test, so it might break if launchdarkly's
176+ implementation changes.
177+ """
178+
179+ ldclient ._reset_client ()
180+ try :
181+ ldclient .__lock .lock ()
182+ ldclient .__config = None
183+ finally :
184+ ldclient .__lock .unlock ()
185+
186+ uninstall_integration (LaunchDarklyIntegration .identifier )
187+ with pytest .raises (DidNotEnable ):
188+ sentry_init (integrations = [LaunchDarklyIntegration ()])
0 commit comments