1#!/usr/bin/env python3
2# Copyright (c) 2023 Intel Corporation
3#
4# SPDX-License-Identifier: Apache-2.0
5"""
6Tests for the error classes
7"""
8
9import os
10import pytest
11
12from pathlib import Path
13from twisterlib.error import StatusAttributeError
14from twisterlib.error import ConfigurationError
15from twisterlib.harness import Test
16
17
18def test_configurationerror():
19    cfile = Path('some') / 'path'
20    message = 'dummy message'
21
22    expected_err = f'{os.path.join("some", "path")}: dummy message'
23
24    with pytest.raises(ConfigurationError, match=expected_err):
25        raise ConfigurationError(cfile, message)
26
27
28def test_status_value_error():
29    harness = Test()
30
31    expected_err = 'Test assigned status OK,' \
32                   ' which could not be cast to a TwisterStatus.'
33
34    with pytest.raises(StatusAttributeError, match=expected_err):
35        harness.status = "OK"
36