From 8466fdfc5c10be9660f4fe6c08b12d74c05c61b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Thu, 14 Mar 2024 09:24:28 +0100 Subject: [PATCH] Add handling for unknown module --- src/ert/config/analysis_config.py | 9 ++++++++- tests/unit_tests/config/test_analysis_config.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ert/config/analysis_config.py b/src/ert/config/analysis_config.py index 6bb55eddf1d..51fc80cef7c 100644 --- a/src/ert/config/analysis_config.py +++ b/src/ert/config/analysis_config.py @@ -126,7 +126,14 @@ def __init__( var_name = "inversion" key = var_name.lower() - options[module_name][key] = value + try: + options[module_name][key] = value + except KeyError: + all_errors.append( + ConfigValidationError( + f"Invalid configuration: ANALYSIS_SET_VAR {module_name} {var_name}" + ) + ) if errors: all_errors.append( diff --git a/tests/unit_tests/config/test_analysis_config.py b/tests/unit_tests/config/test_analysis_config.py index 0f58853ef98..7bf48d8dcdf 100644 --- a/tests/unit_tests/config/test_analysis_config.py +++ b/tests/unit_tests/config/test_analysis_config.py @@ -345,6 +345,10 @@ def test_misfit_configuration(config, expected): [["OBSERVATIONS", "SAUTO_SCALE", "OBS_*"]], pytest.raises(ConfigValidationError, match="Unknown variable"), ), + ( + [["NOT_A_THING", "AUTO_SCALE", "OBS_*"]], + pytest.raises(ConfigValidationError, match="ANALYSIS_SET_VAR NOT_A_THING"), + ), ], ) def test_config_wrong_module(config, expectation):