diff --git a/tests/ert/ui_tests/cli/test_cli.py b/tests/ert/ui_tests/cli/test_cli.py index 40e76212847..1e6ffa65e9c 100644 --- a/tests/ert/ui_tests/cli/test_cli.py +++ b/tests/ert/ui_tests/cli/test_cli.py @@ -41,7 +41,7 @@ @pytest.mark.filterwarnings("ignore::ert.config.ConfigWarning") def test_bad_config_error_message(tmp_path): (tmp_path / "test.ert").write_text("NUM_REL 10\n") - with pytest.raises(ConfigValidationError, match=r"NUM_REALIZATIONS must be set."): + with pytest.raises(ConfigValidationError, match="NUM_REALIZATIONS must be set\\."): run_cli(TEST_RUN_MODE, "--disable-monitor", str(tmp_path / "test.ert")) diff --git a/tests/ert/unit_tests/config/test_analysis_config.py b/tests/ert/unit_tests/config/test_analysis_config.py index f94d832b9ae..8c906464dc1 100644 --- a/tests/ert/unit_tests/config/test_analysis_config.py +++ b/tests/ert/unit_tests/config/test_analysis_config.py @@ -1,3 +1,4 @@ +import re from textwrap import dedent import hypothesis.strategies as st @@ -104,7 +105,9 @@ def test_invalid_min_realization_raises_config_validation_error(): def test_invalid_design_matrix_format_raises_validation_error(): with pytest.raises( ConfigValidationError, - match=r"DESIGN_MATRIX must be of format .xls or .xlsx; is 'my_matrix.txt'", + match=re.escape( + "DESIGN_MATRIX must be of format .xls or .xlsx; is 'my_matrix.txt'" + ), ): AnalysisConfig.from_dict( { diff --git a/tests/ert/unit_tests/config/test_gen_kw_config.py b/tests/ert/unit_tests/config/test_gen_kw_config.py index 1d3df7fa0e3..76beb8eae61 100644 --- a/tests/ert/unit_tests/config/test_gen_kw_config.py +++ b/tests/ert/unit_tests/config/test_gen_kw_config.py @@ -40,7 +40,7 @@ def test_gen_kw_config(): def test_gen_kw_config_duplicate_keys_raises(): with pytest.raises( ConfigValidationError, - match=r"Duplicate GEN_KW keys 'KEY2' found, keys must be unique.", + match=re.escape("Duplicate GEN_KW keys 'KEY2' found, keys must be unique."), ): GenKwConfig( name="KEY", diff --git a/tests/ert/unit_tests/config/test_surface_config.py b/tests/ert/unit_tests/config/test_surface_config.py index 89a01864fe7..3435d2a21cd 100644 --- a/tests/ert/unit_tests/config/test_surface_config.py +++ b/tests/ert/unit_tests/config/test_surface_config.py @@ -98,7 +98,7 @@ def test_init_files_must_contain_placeholder_when_not_forward_init(): def test_when_base_surface_does_not_exist_gives_config_error(): with pytest.raises( ConfigValidationError, - match=r"surface/small_out.irap not found", + match="surface/small_out\\.irap not found", ): SurfaceConfig.from_config_list( [ @@ -180,7 +180,7 @@ def test_config_file_line_sets_the_corresponding_properties( def test_invalid_surface_files_gives_config_error(): Path("base_surface.irap").write_text("not valid irap", encoding="utf-8") with pytest.raises( - ConfigValidationError, match=r"Could not load surface 'base_surface.irap'" + ConfigValidationError, match="Could not load surface 'base_surface\\.irap'" ): _ = SurfaceConfig.from_config_list( [ diff --git a/tests/ert/unit_tests/plugins/test_export_runpath.py b/tests/ert/unit_tests/plugins/test_export_runpath.py index 58cb48ca2b8..d63693b1a51 100644 --- a/tests/ert/unit_tests/plugins/test_export_runpath.py +++ b/tests/ert/unit_tests/plugins/test_export_runpath.py @@ -80,7 +80,7 @@ def test_export_runpath_combination_parameter(writing_setup): def test_export_runpath_bad_arguments(writing_setup): writing_setup, config = writing_setup - with pytest.raises(ValueError, match=r"Expected |"): + with pytest.raises(ValueError, match="Expected \\|"): writing_setup.export_job.run(config, ["wat"]) diff --git a/tests/ert/unit_tests/resources/test_ecl_versioning_config.py b/tests/ert/unit_tests/resources/test_ecl_versioning_config.py index 7ed22546c4c..6e61d4909f7 100644 --- a/tests/ert/unit_tests/resources/test_ecl_versioning_config.py +++ b/tests/ert/unit_tests/resources/test_ecl_versioning_config.py @@ -46,7 +46,7 @@ def test_loading_of_eclipse_configurations(monkeypatch): f.write("this:\n -should\n-be\ninvalid:yaml?") monkeypatch.setenv("ECL100_SITE_CONFIG", "file.yml") - with pytest.raises(ValueError, match=r"Failed parse: file.yml as yaml"): + with pytest.raises(ValueError, match="Failed parse: file\\.yml as yaml"): conf = ecl_config.Ecl100Config() scalar_exe = "bin/scalar_exe" diff --git a/tests/ert/unit_tests/storage/test_local_storage.py b/tests/ert/unit_tests/storage/test_local_storage.py index 529c1008c71..6af08935b7d 100644 --- a/tests/ert/unit_tests/storage/test_local_storage.py +++ b/tests/ert/unit_tests/storage/test_local_storage.py @@ -109,7 +109,7 @@ def test_that_saving_empty_responses_fails_nicely(tmp_path): with pytest.raises( ValueError, - match=r"Responses RESPONSE are empty. Cannot proceed with saving to storage.", + match="Responses RESPONSE are empty\\. Cannot proceed with saving to storage\\.", ): ensemble.save_response("RESPONSE", empty_data, 0) @@ -193,7 +193,7 @@ def test_that_saving_empty_parameters_fails_nicely(tmp_path): ) with pytest.raises( ValueError, - match=r"Parameters PARAMETER are empty. Cannot proceed with saving to storage.", + match="Parameters PARAMETER are empty\\. Cannot proceed with saving to storage\\.", ): prior.save_parameters("PARAMETER", 0, empty_data) @@ -361,7 +361,7 @@ def test_open_storage_with_corrupted_storage(tmp_path): with open_storage(tmp_path / "storage", mode="w") as storage: storage.create_experiment().create_ensemble(name="prior", ensemble_size=1) os.remove(tmp_path / "storage" / "index.json") - with pytest.raises(ErtStorageException, match=r"No index.json"): + with pytest.raises(ErtStorageException, match="No index\\.json"): open_storage(tmp_path / "storage", mode="w") diff --git a/tests/ert/unit_tests/storage/test_parameter_sample_types.py b/tests/ert/unit_tests/storage/test_parameter_sample_types.py index 8842683f901..9e68be85503 100644 --- a/tests/ert/unit_tests/storage/test_parameter_sample_types.py +++ b/tests/ert/unit_tests/storage/test_parameter_sample_types.py @@ -595,8 +595,8 @@ def test_gen_kw_forward_init(tmpdir, storage, load_forward_init): with pytest.raises( ConfigValidationError, match=( - r"Loading GEN_KW from files created by " - r"the forward model is not supported." + "Loading GEN_KW from files created by " + "the forward model is not supported\\." ), ): create_runpath(storage, "config.ert") diff --git a/tests/everest/test_controls.py b/tests/everest/test_controls.py index c6250e08997..4b51b6db9fa 100644 --- a/tests/everest/test_controls.py +++ b/tests/everest/test_controls.py @@ -154,8 +154,8 @@ def test_variable_name_index_validation(copy_test_data_to_tmp): config.input_constraints = input_constraints with pytest.raises( ValidationError, - match=r"does not match any instance of " - r"control_name.variable_name-variable_index", + match="does not match any instance of " + "control_name\\.variable_name-variable_index", ): EverestConfig.model_validate(config.model_dump(exclude_none=True))