From 19f30771952323cd7e73bf8a3a456642dc6b5be0 Mon Sep 17 00:00:00 2001 From: Matjaz Pirnovar Date: Mon, 11 Mar 2024 12:52:34 -0700 Subject: [PATCH] upate to generic exception --- optimizely/config_manager.py | 2 +- tests/test_config_manager.py | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/optimizely/config_manager.py b/optimizely/config_manager.py index a4ca91f2..755c6b9c 100644 --- a/optimizely/config_manager.py +++ b/optimizely/config_manager.py @@ -420,7 +420,7 @@ def _run(self) -> None: if self.stopped.wait(self.update_interval): self.stopped.clear() break - except (OSError, OverflowError) as err: + except Exception as err: self.logger.error( f'Thread for background datafile polling failed. Error: {err}' ) diff --git a/tests/test_config_manager.py b/tests/test_config_manager.py index 929609c2..1c3fbe89 100644 --- a/tests/test_config_manager.py +++ b/tests/test_config_manager.py @@ -507,19 +507,18 @@ def test_fetch_datafile__exception_polling_thread_failed(self, _): test_response._content = test_datafile with mock.patch('requests.get', return_value=test_response): - with self.assertRaises(OverflowError): - project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key, - logger=mock_logger, - update_interval=12345678912345) - - project_config_manager.stop() - - # verify the error log message - log_messages = [args[0] for args, _ in mock_logger.error.call_args_list] - for message in log_messages: - if "Thread for background datafile polling failed. " \ - "Error: timestamp too large to convert to C _PyTime_t" not in message: - assert False + project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key, + logger=mock_logger, + update_interval=12345678912345) + + project_config_manager.stop() + + # verify the error log message + log_messages = [args[0] for args, _ in mock_logger.error.call_args_list] + for message in log_messages: + if "Thread for background datafile polling failed. " \ + "Error: timestamp too large to convert to C _PyTime_t" not in message: + assert False def test_is_running(self, _): """ Test that polling thread is running after instance of PollingConfigManager is created. """