diff --git a/pyproject.toml b/pyproject.toml index 6b82ec3cc..fcdd5f863 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,8 @@ dependencies = [ [tool.hatch.envs.test.scripts] install = "make PREFIX=$VIRTUAL_ENV install" +devinstall = "pip install -U pip && pip install -e ." +dotest = "pytest {args}" clean-test = "rm -f .coverage* cobertura.xml && rm -fr .pytest_cache" run-unit = "pytest -m unit --no-cov --cache-clear tests" run-integration = "pytest -m integration --no-cov --cache-clear tests" diff --git a/src/ramstk/analyses/fha.py b/src/ramstk/analyses/fha.py index b7a84d42a..d48a07164 100644 --- a/src/ramstk/analyses/fha.py +++ b/src/ramstk/analyses/fha.py @@ -69,7 +69,11 @@ def calculate_hri(probability: str, severity: str) -> int: return PROBABILITY[probability] * SEVERITY[severity] except KeyError as _error: raise OutOfRangeError( - (f"Unknown hazard probability ({probability}) or severity ({severity}).") + ( + f"Invalid hazard input: probability ({probability}) or severity " + f"({severity}) not recognized. Expected ranges: probability 1-5, " + f"severity I-IV." + ) ) from _error diff --git a/tests/analyses/test_fha.py b/tests/analyses/test_fha.py index f15ea3a51..83184180d 100644 --- a/tests/analyses/test_fha.py +++ b/tests/analyses/test_fha.py @@ -59,7 +59,8 @@ def test_calculate_hri_unknown_probability(): with pytest.raises(OutOfRangeError) as e: fha.calculate_hri("shibboly-biboly-boo", "Medium") assert e.value.args[0] == ( - "Unknown hazard probability (shibboly-biboly-boo) or severity (Medium)." + "Invalid hazard input: probability (shibboly-biboly-boo) or severity (Medium) " + "not recognized. Expected ranges: probability 1-5, severity I-IV." ) @@ -71,7 +72,9 @@ def test_calculate_hri_unknown_severity(): with pytest.raises(OutOfRangeError) as e: fha.calculate_hri("Level A - Frequent", "shibboly-biboly-boo") assert e.value.args[0] == ( - "Unknown hazard probability (Level A - Frequent) or severity (shibboly-biboly-boo)." + "Invalid hazard input: probability (Level A - Frequent) or severity " + "(shibboly-biboly-boo) not recognized. Expected ranges: probability 1-5, " + "severity I-IV." ) @@ -242,9 +245,9 @@ def test_calculate_hri_non_string_input(): @pytest.mark.unit @pytest.mark.calculation def test_set_user_defined_function_invalid_equation(): - """calculate_user_defined() should raise a SympifyError for invalid equations.""" + """calculate_user_defined() should raise a ValueError for invalid equations.""" with pytest.raises(ValueError): - _fha = fha.set_user_defined_functions(TEST_FHA, ["uf1+uf2", "invalid_equation"]) + fha.set_user_defined_functions(TEST_FHA, ["uf1+uf2", "invalid_equation"]) @pytest.mark.unit