From 17e4a77ec7641d98c12fb0368f2f42a6eb86ff5e Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Wed, 3 Jul 2024 16:33:31 +0300 Subject: [PATCH] ref(tests): Unhardcode integration list Benefits of unhardcoding integration list and disabling auto integrations: 1. It becomes possible to successfully run tests in environments where certain extra auto integrations get enabled. 2. There is no need to update hardcoded list when new default integrations are introduced. --- .../test_new_scopes_compat_event.py | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/tests/new_scopes_compat/test_new_scopes_compat_event.py b/tests/new_scopes_compat/test_new_scopes_compat_event.py index fd43a25c69..db1e5fec4b 100644 --- a/tests/new_scopes_compat/test_new_scopes_compat_event.py +++ b/tests/new_scopes_compat/test_new_scopes_compat_event.py @@ -4,6 +4,7 @@ import sentry_sdk from sentry_sdk.hub import Hub +from sentry_sdk.integrations import iter_default_integrations from sentry_sdk.scrubber import EventScrubber, DEFAULT_DENYLIST @@ -18,7 +19,17 @@ @pytest.fixture -def expected_error(): +def integrations(): + return [ + integration.identifier + for integration in iter_default_integrations( + with_auto_enabling_integrations=False + ) + ] + + +@pytest.fixture +def expected_error(integrations): def create_expected_error_event(trx, span): return { "level": "warning-X", @@ -122,16 +133,7 @@ def create_expected_error_event(trx, span): "name": "sentry.python", "version": mock.ANY, "packages": [{"name": "pypi:sentry-sdk", "version": mock.ANY}], - "integrations": [ - "argv", - "atexit", - "dedupe", - "excepthook", - "logging", - "modules", - "stdlib", - "threading", - ], + "integrations": integrations, }, "platform": "python", "_meta": { @@ -149,7 +151,7 @@ def create_expected_error_event(trx, span): @pytest.fixture -def expected_transaction(): +def expected_transaction(integrations): def create_expected_transaction_event(trx, span): return { "type": "transaction", @@ -220,16 +222,7 @@ def create_expected_transaction_event(trx, span): "name": "sentry.python", "version": mock.ANY, "packages": [{"name": "pypi:sentry-sdk", "version": mock.ANY}], - "integrations": [ - "argv", - "atexit", - "dedupe", - "excepthook", - "logging", - "modules", - "stdlib", - "threading", - ], + "integrations": integrations, }, "platform": "python", "_meta": { @@ -328,6 +321,7 @@ def _init_sentry_sdk(sentry_init): ), send_default_pii=False, traces_sample_rate=1.0, + auto_enabling_integrations=False, )