From 0acb4abcef12e670a2c27aa8e59111f558596d3b Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 20 Sep 2024 15:01:47 -0700 Subject: [PATCH] Add backwards-compat. patching with deprecation warning --- neon_utils/signal_utils.py | 18 ++++++++++++++---- tests/neon_skill_tests.py | 1 - tests/signal_util_tests.py | 1 - 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/neon_utils/signal_utils.py b/neon_utils/signal_utils.py index a2db777b..d9b696c5 100644 --- a/neon_utils/signal_utils.py +++ b/neon_utils/signal_utils.py @@ -136,10 +136,20 @@ def init_signal_handlers(): else: LOG.warning("FS signals are deprecated. Signal methods will have no effect.") - _create_signal = Mock(return_value=False) - _check_for_signal = Mock(return_value=False) - _wait_for_signal_clear = Mock(return_value=False) - _wait_for_signal_create = Mock(return_value=False) + if patch_imports: + log_deprecation("Import patching will be deprecated. Disable in " + "configuration by setting `signal`.`patch_imports` " + "to `False`", "2.0.0") + import ovos_utils.signal + _create_signal = ovos_utils.signal.create_signal + _check_for_signal = ovos_utils.signal.check_for_signal + _wait_for_signal_clear = _fs_wait_for_signal_clear + _wait_for_signal_create = _fs_wait_for_signal_create + else: + _create_signal = Mock(return_value=False) + _check_for_signal = Mock(return_value=False) + _wait_for_signal_clear = Mock(return_value=False) + _wait_for_signal_create = Mock(return_value=False) def check_signal_manager_available() -> bool: diff --git a/tests/neon_skill_tests.py b/tests/neon_skill_tests.py index b5b75a7b..514132ab 100644 --- a/tests/neon_skill_tests.py +++ b/tests/neon_skill_tests.py @@ -1015,7 +1015,6 @@ def test_speak_emit_response_valid(self): message.context.pop('destination') self.assertEqual(message.context, msg.context) - @unittest.skip("Class is deprecated and test fails with signal deprecation") def test_speak_wait(self): from neon_utils.signal_utils import create_signal, check_for_signal, \ wait_for_signal_clear diff --git a/tests/signal_util_tests.py b/tests/signal_util_tests.py index 795449bd..7c0d9f15 100644 --- a/tests/signal_util_tests.py +++ b/tests/signal_util_tests.py @@ -157,7 +157,6 @@ def test_signal_utils_manager_available(self): self.assertEqual(ovos_utils.signal.create_signal, neon_utils.signal_utils._manager_create_signal) - @unittest.skip("File-based signal handling is deprecated") def test_signal_utils_manager_unavailable(self): import ovos_utils.signal neon_utils.signal_utils.init_signal_handlers()