python-sentry-sdk/0002-ref-tests-Unhardcode-integration-list.patch
Roman Inflianskas 44c6a5e84a
Add Patch1 back
The line:
`Patch1: 0002-tests.test_new_scopes_compat_event-compatibility.patch`
was removed in commit `987e25d`, though it was still needed for tests to
pass. The tests did not run because they were disabled in commit `7501b73`.
The patch was reintroduced again, now in an upstreamable fashion.

[skip changelog]
2024-07-19 20:08:27 +03:00

102 lines
3.2 KiB
Diff

From da4ce6fe9d4cfde58bca5255fc501714f3a286e6 Mon Sep 17 00:00:00 2001
From: Roman Inflianskas <rominf@pm.me>
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 integrations get enabled.
2. There is no need to update hardcoded list when new default
integrations are introduced.
---
tests/test_new_scopes_compat_event.py | 38 +++++++++++----------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/tests/test_new_scopes_compat_event.py b/tests/test_new_scopes_compat_event.py
index 53eb095b..91bfab43 100644
--- a/tests/test_new_scopes_compat_event.py
+++ b/tests/test_new_scopes_compat_event.py
@@ -4,6 +4,7 @@ from unittest import mock
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 @@ This makes sure that we are backwards compatible. (on a best effort basis, there
@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 expected_error():
"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 expected_error():
@pytest.fixture
-def expected_transaction():
+def expected_transaction(integrations):
def create_expected_transaction_event(trx, span):
return {
"type": "transaction",
@@ -220,16 +222,7 @@ def expected_transaction():
"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,
)
--
2.45.2