Skip to content

Commit

Permalink
ref(tests): Unhardcode integration list
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rominf committed Jul 3, 2024
1 parent 407f651 commit 15ce0f2
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions tests/test_new_scopes_compat_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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",
Expand Down Expand Up @@ -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": {
Expand All @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -328,6 +321,7 @@ def _init_sentry_sdk(sentry_init):
),
send_default_pii=False,
traces_sample_rate=1.0,
auto_enabling_integrations=False,
)


Expand Down

0 comments on commit 15ce0f2

Please sign in to comment.