Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ocp_resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def __iter__(self):

time.sleep(self.sleep)

except self._exceptions as exp:
except Exception as exp:
last_exp = exp
last_exp_log = self._get_exception_log(exp=last_exp)
if self._is_raisable_exception(exp=last_exp):
LOGGER.error(last_exp_log)
raise exp
raise TimeoutExpiredError(self._get_exception_log(exp=last_exp))

self.elapsed_time = None
time.sleep(self.sleep)
Expand Down
15 changes: 3 additions & 12 deletions tests/unittests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _trigger_func_exception_during_iter(self, exceptions_dict, runtime_exception
continue

@pytest.mark.parametrize(
"test_params, expected",
"test_params",
[
pytest.param(
{
Expand All @@ -32,9 +32,6 @@ def _trigger_func_exception_during_iter(self, exceptions_dict, runtime_exception
},
"runtime_exception": ValueError(),
},
{
"raises": ValueError,
},
id="init_keyerror_raise_valueerror_with_no_msg",
),
pytest.param(
Expand All @@ -44,9 +41,6 @@ def _trigger_func_exception_during_iter(self, exceptions_dict, runtime_exception
},
"runtime_exception": ValueError("test"),
},
{
"raises": ValueError,
},
id="init_valueerror_with_msg_raise_valueerror_with_invalid_msg",
),
pytest.param(
Expand All @@ -58,15 +52,12 @@ def _trigger_func_exception_during_iter(self, exceptions_dict, runtime_exception
},
"runtime_exception": IndexError("test"),
},
{
"raises": IndexError,
},
id="init_multi_exceptions_raise_allowed_with_invalid_msg",
),
],
)
def test_timeout_sampler_raises(self, test_params, expected):
with pytest.raises(expected["raises"]):
def test_timeout_sampler_raises(self, test_params):
with pytest.raises(TimeoutExpiredError):
self._trigger_func_exception_during_iter(
exceptions_dict=test_params.get("init_exceptions_dict"),
runtime_exception=test_params.get("runtime_exception"),
Expand Down