diff --git a/scripts/pylib/twister/twisterlib/error.py b/scripts/pylib/twister/twisterlib/error.py index adccde7742737e..26180653a95143 100644 --- a/scripts/pylib/twister/twisterlib/error.py +++ b/scripts/pylib/twister/twisterlib/error.py @@ -11,9 +11,7 @@ class TwisterException(Exception): def __init__(self, message="TwisterException"): super().__init__(message) - for line in traceback.format_stack(): - logger.info(line.strip()) - logger.warning("======call stack dump end============") + logger.error(''.join(["Twister call stack dump:\n"] + traceback.format_stack()[:-1])) class TwisterRuntimeError(TwisterException): pass diff --git a/scripts/tests/twister/test_errors.py b/scripts/tests/twister/test_errors.py index 8968b6a1fa1e40..0396ee109f8f43 100644 --- a/scripts/tests/twister/test_errors.py +++ b/scripts/tests/twister/test_errors.py @@ -28,8 +28,8 @@ def test_configurationerror(): def test_status_value_error(): harness = Test() - expected_err = 'Test assigned status None,' \ + expected_err = 'Test assigned status OK,' \ ' which could not be cast to a TwisterStatus.' with pytest.raises(StatusAttributeError, match=expected_err): - harness.status = None + harness.status = "OK" diff --git a/scripts/tests/twister/test_handlers.py b/scripts/tests/twister/test_handlers.py index 4c5730cdd03a89..de2ac883df081b 100644 --- a/scripts/tests/twister/test_handlers.py +++ b/scripts/tests/twister/test_handlers.py @@ -131,7 +131,7 @@ def test_handler_final_handle_actions(mocked_instance): handler.suite_name_check = True harness = twisterlib.harness.Test() - harness.status = 'NONE' + harness.status = TwisterStatus.NONE harness.detected_suite_names = mock.Mock() harness.matched_run_id = False harness.run_id_exists = True diff --git a/scripts/tests/twister/test_testsuite.py b/scripts/tests/twister/test_testsuite.py index 8d20902a5ebaf1..83231c0f48adab 100644 --- a/scripts/tests/twister/test_testsuite.py +++ b/scripts/tests/twister/test_testsuite.py @@ -648,7 +648,10 @@ def mock_sf(filename, *args, **kwargs): def mock_stat(filename, *args, **kwargs): result = mock.Mock() - type(result).st_size = sizes[filename] + # as we may call os.stat in code + # some protection need add here + if filename in sizes: + type(result).st_size = sizes[filename] return result