Skip to content

Commit 7a7874d

Browse files
authored
ref(tests): Unhardcode integration list (#3240)
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.
1 parent 41e4bb4 commit 7a7874d

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

tests/new_scopes_compat/test_new_scopes_compat_event.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import sentry_sdk
66
from sentry_sdk.hub import Hub
7+
from sentry_sdk.integrations import iter_default_integrations
78
from sentry_sdk.scrubber import EventScrubber, DEFAULT_DENYLIST
89

910

@@ -18,7 +19,17 @@
1819

1920

2021
@pytest.fixture
21-
def expected_error():
22+
def integrations():
23+
return [
24+
integration.identifier
25+
for integration in iter_default_integrations(
26+
with_auto_enabling_integrations=False
27+
)
28+
]
29+
30+
31+
@pytest.fixture
32+
def expected_error(integrations):
2233
def create_expected_error_event(trx, span):
2334
return {
2435
"level": "warning-X",
@@ -122,16 +133,7 @@ def create_expected_error_event(trx, span):
122133
"name": "sentry.python",
123134
"version": mock.ANY,
124135
"packages": [{"name": "pypi:sentry-sdk", "version": mock.ANY}],
125-
"integrations": [
126-
"argv",
127-
"atexit",
128-
"dedupe",
129-
"excepthook",
130-
"logging",
131-
"modules",
132-
"stdlib",
133-
"threading",
134-
],
136+
"integrations": integrations,
135137
},
136138
"platform": "python",
137139
"_meta": {
@@ -149,7 +151,7 @@ def create_expected_error_event(trx, span):
149151

150152

151153
@pytest.fixture
152-
def expected_transaction():
154+
def expected_transaction(integrations):
153155
def create_expected_transaction_event(trx, span):
154156
return {
155157
"type": "transaction",
@@ -220,16 +222,7 @@ def create_expected_transaction_event(trx, span):
220222
"name": "sentry.python",
221223
"version": mock.ANY,
222224
"packages": [{"name": "pypi:sentry-sdk", "version": mock.ANY}],
223-
"integrations": [
224-
"argv",
225-
"atexit",
226-
"dedupe",
227-
"excepthook",
228-
"logging",
229-
"modules",
230-
"stdlib",
231-
"threading",
232-
],
225+
"integrations": integrations,
233226
},
234227
"platform": "python",
235228
"_meta": {
@@ -328,6 +321,7 @@ def _init_sentry_sdk(sentry_init):
328321
),
329322
send_default_pii=False,
330323
traces_sample_rate=1.0,
324+
auto_enabling_integrations=False,
331325
)
332326

333327

0 commit comments

Comments
 (0)