|
19 | 19 | ################ |
20 | 20 |
|
21 | 21 |
|
| 22 | +@pytest.fixture(scope="function") |
| 23 | +def sentry_init_with_reset(sentry_init): |
| 24 | + from sentry_sdk.integrations import _processed_integrations |
| 25 | + |
| 26 | + yield lambda: sentry_init(integrations=[SparkIntegration()]) |
| 27 | + _processed_integrations.remove("spark") |
| 28 | + |
| 29 | + |
22 | 30 | @pytest.fixture(scope="function") |
23 | 31 | def create_spark_context(): |
24 | 32 | yield lambda: SparkContext(appName="Testing123") |
@@ -48,31 +56,26 @@ def test_start_sentry_listener(create_spark_context): |
48 | 56 | assert gateway._callback_server is not None |
49 | 57 |
|
50 | 58 |
|
51 | | -def test_initialize_spark_integration(sentry_init, create_spark_context): |
52 | | - sentry_init(integrations=[SparkIntegration()]) |
53 | | - create_spark_context() |
54 | | - |
55 | | - |
56 | | -@patch("sentry_sdk.integrations.spark.spark_driver._activate_integration") |
| 59 | +@patch("sentry_sdk.integrations.spark.spark_driver._patch_spark_context_init") |
57 | 60 | def test_initialize_spark_integration_before_spark_context_init( |
58 | | - mock_activate_integration, |
59 | | - sentry_init, |
| 61 | + mock_patch_spark_context_init, |
| 62 | + sentry_init_with_reset, |
60 | 63 | create_spark_context, |
61 | 64 | ): |
62 | | - sentry_init(integrations=[SparkIntegration()]) |
| 65 | + sentry_init_with_reset() |
63 | 66 | create_spark_context() |
64 | 67 |
|
65 | | - mock_activate_integration.assert_called_once() |
| 68 | + mock_patch_spark_context_init.assert_called_once() |
66 | 69 |
|
67 | 70 |
|
68 | 71 | @patch("sentry_sdk.integrations.spark.spark_driver._activate_integration") |
69 | 72 | def test_initialize_spark_integration_after_spark_context_init( |
70 | 73 | mock_activate_integration, |
71 | 74 | create_spark_context, |
72 | | - sentry_init, |
| 75 | + sentry_init_with_reset, |
73 | 76 | ): |
74 | 77 | create_spark_context() |
75 | | - sentry_init(integrations=[SparkIntegration()]) |
| 78 | + sentry_init_with_reset() |
76 | 79 |
|
77 | 80 | mock_activate_integration.assert_called_once() |
78 | 81 |
|
|
0 commit comments