From 9363b3721b50e3a5695bb3877aefac177934c93b 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 aa01ca555a0..e7dd6f8ae9d 100644 --- a/src/ert/config/analysis_config.py +++ b/src/ert/config/analysis_config.py @@ -117,7 +117,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 1f221fb3078..e5f9dda4ce5 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):