From 6af8cd4db206b1c8546bdb47c2aede32297afb82 Mon Sep 17 00:00:00 2001 From: seyoon-lim Date: Sat, 10 Aug 2024 12:27:55 +0900 Subject: [PATCH] Fix: applied sentry_init_with_reset fixture --- tests/integrations/spark/test_spark.py | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/integrations/spark/test_spark.py b/tests/integrations/spark/test_spark.py index 6146c4714c..9ad54a1f1b 100644 --- a/tests/integrations/spark/test_spark.py +++ b/tests/integrations/spark/test_spark.py @@ -19,6 +19,14 @@ ################ +@pytest.fixture(scope="function") +def sentry_init_with_reset(sentry_init): + from sentry_sdk.integrations import _processed_integrations + + yield lambda: sentry_init(integrations=[SparkIntegration()]) + _processed_integrations.remove("spark") + + @pytest.fixture(scope="function") def create_spark_context(): yield lambda: SparkContext(appName="Testing123") @@ -48,31 +56,26 @@ def test_start_sentry_listener(create_spark_context): assert gateway._callback_server is not None -def test_initialize_spark_integration(sentry_init, create_spark_context): - sentry_init(integrations=[SparkIntegration()]) - create_spark_context() - - -@patch("sentry_sdk.integrations.spark.spark_driver._activate_integration") +@patch("sentry_sdk.integrations.spark.spark_driver._patch_spark_context_init") def test_initialize_spark_integration_before_spark_context_init( - mock_activate_integration, - sentry_init, + mock_patch_spark_context_init, + sentry_init_with_reset, create_spark_context, ): - sentry_init(integrations=[SparkIntegration()]) + sentry_init_with_reset() create_spark_context() - mock_activate_integration.assert_called_once() + mock_patch_spark_context_init.assert_called_once() @patch("sentry_sdk.integrations.spark.spark_driver._activate_integration") def test_initialize_spark_integration_after_spark_context_init( mock_activate_integration, create_spark_context, - sentry_init, + sentry_init_with_reset, ): create_spark_context() - sentry_init(integrations=[SparkIntegration()]) + sentry_init_with_reset() mock_activate_integration.assert_called_once()