zephyr/scripts/tests/twister/test_errors.py
Lukasz Mrugala 345eb8e94a scripts: twister: Elevate Status Error
Status errors previously logged an error, but didn't fail the running test.
This commit changes that
 and introduces a new StatusAttributeError to use there.

One test is modified so it follows proper status form.
One test for the new error has been added.

Status errors now will properly mark the Instance as ERROR
and not run TestCases as SKIP.
This necessitated some code layout changes in runner.py

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-09-09 09:28:37 +02:00

35 lines
871 B
Python

#!/usr/bin/env python3
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
"""
Tests for the error classes
"""
import os
import pytest
from pathlib import Path
from twisterlib.error import StatusAttributeError
from twisterlib.error import ConfigurationError
from twisterlib.harness import Test
def test_configurationerror():
cfile = Path('some') / 'path'
message = 'dummy message'
expected_err = f'{os.path.join("some", "path")}: dummy message'
with pytest.raises(ConfigurationError, match=expected_err):
raise ConfigurationError(cfile, message)
def test_status_value_error():
harness = Test()
expected_err = 'Test assigned status None,' \
' which could not be cast to a TwisterStatus.'
with pytest.raises(StatusAttributeError, match=expected_err):
harness.status = None