From d552f9ddd2d2697d5409730bcd3a2cb099279c96 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Wed, 13 Mar 2024 18:27:02 +0000 Subject: [PATCH] skip tests on macos because `multiprocess` default switch to `spawn` since Python 3.8 (#3705) * add docs for line magic Signed-off-by: Nok Lam Chan * Skip test in MacOS Signed-off-by: Nok Lam Chan * revert changes Signed-off-by: Nok Lam Chan * lint Signed-off-by: Nok Lam Chan --------- Signed-off-by: Nok Lam Chan --- .../session/test_session_extension_hooks.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/framework/session/test_session_extension_hooks.py b/tests/framework/session/test_session_extension_hooks.py index c8f3729feb..879cfe3e73 100644 --- a/tests/framework/session/test_session_extension_hooks.py +++ b/tests/framework/session/test_session_extension_hooks.py @@ -1,6 +1,6 @@ import logging +import multiprocessing import re -import sys import time from typing import Any @@ -30,8 +30,11 @@ assert_exceptions_equal, ) -SKIP_ON_WINDOWS = pytest.mark.skipif( - sys.platform.startswith("win"), reason="Due to bug in parallel runner" +# Window and MacOS(Python>3.7) default with `spawn` process which reload modules +# and cause test fails +SKIP_ON_WINDOWS_AND_MACOS = pytest.mark.skipif( + multiprocessing.get_start_method() == "spawn", + reason="Due to bug in parallel runner", ) logger = logging.getLogger("tests.framework.session.conftest") @@ -233,7 +236,7 @@ def test_before_and_after_node_run_hooks_sequential_runner( # sanity check a couple of important parameters assert call_record.outputs["planes"].to_dict() == dummy_dataframe.to_dict() - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS @pytest.mark.usefixtures("mock_broken_pipelines") def test_on_node_error_hook_parallel_runner(self, mock_session, logs_listener): with pytest.raises(ValueError, match="broken"): @@ -254,7 +257,7 @@ def test_on_node_error_hook_parallel_runner(self, mock_session, logs_listener): expected_error = ValueError("broken") assert_exceptions_equal(call_record.error, expected_error) - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS @pytest.mark.usefixtures("mock_pipelines") def test_before_and_after_node_run_hooks_parallel_runner( self, mock_session, logs_listener, dummy_dataframe @@ -322,7 +325,7 @@ def test_before_and_after_dataset_loaded_hooks_sequential_runner( assert call_record.dataset_name == "cars" pd.testing.assert_frame_equal(call_record.data, dummy_dataframe) - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS @pytest.mark.usefixtures("mock_settings") def test_before_and_after_dataset_loaded_hooks_parallel_runner( self, mock_session, logs_listener, dummy_dataframe @@ -388,7 +391,7 @@ def test_before_and_after_dataset_saved_hooks_sequential_runner( assert call_record.dataset_name == "planes" assert call_record.data.to_dict() == dummy_dataframe.to_dict() - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS def test_before_and_after_dataset_saved_hooks_parallel_runner( self, mock_session, logs_listener, dummy_dataframe ): @@ -475,7 +478,7 @@ def test_correct_input_update( assert isinstance(result["planes"], MockDatasetReplacement) assert isinstance(result["ships"], pd.DataFrame) - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS def test_correct_input_update_parallel( self, mock_session_with_before_node_run_hooks, @@ -505,7 +508,7 @@ def test_broken_input_update( with pytest.raises(TypeError, match=re.escape(pattern)): mock_session_with_broken_before_node_run_hooks.run() - @SKIP_ON_WINDOWS + @SKIP_ON_WINDOWS_AND_MACOS def test_broken_input_update_parallel( self, mock_session_with_broken_before_node_run_hooks, dummy_dataframe ):