Skip to content

Commit 9ebee27

Browse files
committed
Use identifier
1 parent 633b3ed commit 9ebee27

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

tests/conftest.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,9 @@ def reset_integrations():
187187

188188
@pytest.fixture
189189
def uninstall_integration():
190-
"""
191-
Forces the next call to sentry_init to re-install an integration and call `setup_once`.
192-
No effect if the integration is not installed.
193-
"""
190+
"""Use to force the next call to sentry_init to re-install/setup an integration."""
194191

195-
def inner(name_or_cls):
196-
if isinstance(name_or_cls, str):
197-
identifier = name_or_cls
198-
else:
199-
identifier = name_or_cls.identifier
192+
def inner(identifier):
200193
_processed_integrations.discard(identifier)
201194
_installed_integrations.discard(identifier)
202195

tests/integrations/unleash/test_unleash.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def test_is_enabled(sentry_init, capture_events, uninstall_integration):
15-
uninstall_integration(UnleashIntegration)
15+
uninstall_integration(UnleashIntegration.identifier)
1616

1717
with mock_unleash_client():
1818
client = UnleashClient()
@@ -35,7 +35,7 @@ def test_is_enabled(sentry_init, capture_events, uninstall_integration):
3535

3636

3737
def test_get_variant(sentry_init, capture_events, uninstall_integration):
38-
uninstall_integration(UnleashIntegration)
38+
uninstall_integration(UnleashIntegration.identifier)
3939

4040
with mock_unleash_client():
4141
client = UnleashClient()
@@ -64,7 +64,7 @@ def test_get_variant(sentry_init, capture_events, uninstall_integration):
6464

6565

6666
def test_is_enabled_threaded(sentry_init, capture_events, uninstall_integration):
67-
uninstall_integration(UnleashIntegration)
67+
uninstall_integration(UnleashIntegration.identifier)
6868

6969
with mock_unleash_client():
7070
client = UnleashClient()
@@ -113,7 +113,7 @@ def task(flag_key):
113113

114114

115115
def test_get_variant_threaded(sentry_init, capture_events, uninstall_integration):
116-
uninstall_integration(UnleashIntegration)
116+
uninstall_integration(UnleashIntegration.identifier)
117117

118118
with mock_unleash_client():
119119
client = UnleashClient()
@@ -164,7 +164,7 @@ def task(flag_key):
164164
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")
165165
def test_is_enabled_asyncio(sentry_init, capture_events, uninstall_integration):
166166
asyncio = pytest.importorskip("asyncio")
167-
uninstall_integration(UnleashIntegration)
167+
uninstall_integration(UnleashIntegration.identifier)
168168

169169
with mock_unleash_client():
170170
client = UnleashClient()
@@ -216,7 +216,7 @@ async def runner():
216216
def test_get_variant_asyncio(sentry_init, capture_events, uninstall_integration):
217217
asyncio = pytest.importorskip("asyncio")
218218

219-
uninstall_integration(UnleashIntegration)
219+
uninstall_integration(UnleashIntegration.identifier)
220220

221221
with mock_unleash_client():
222222
client = UnleashClient()
@@ -273,7 +273,7 @@ def test_wraps_original(sentry_init, uninstall_integration):
273273
client.is_enabled = mock_is_enabled
274274
client.get_variant = mock_get_variant
275275

276-
uninstall_integration(UnleashIntegration)
276+
uninstall_integration(UnleashIntegration.identifier)
277277
sentry_init(integrations=[UnleashIntegration()]) # type: ignore
278278

279279
res = client.is_enabled("test-flag", "arg", kwarg=1)
@@ -298,7 +298,7 @@ def test_wrapper_attributes(sentry_init, uninstall_integration):
298298
original_is_enabled = client.is_enabled
299299
original_get_variant = client.get_variant
300300

301-
uninstall_integration(UnleashIntegration)
301+
uninstall_integration(UnleashIntegration.identifier)
302302
sentry_init(integrations=[UnleashIntegration()]) # type: ignore
303303

304304
# Mock clients methods have not lost their qualified names after decoration.

0 commit comments

Comments
 (0)