diff --git a/tests/unit_tests/config/test_analysis_config.py b/tests/unit_tests/config/test_analysis_config.py index dc09b1b34c8..900c3bc2c86 100644 --- a/tests/unit_tests/config/test_analysis_config.py +++ b/tests/unit_tests/config/test_analysis_config.py @@ -1,4 +1,3 @@ -import warnings from textwrap import dedent import hypothesis.strategies as st @@ -265,13 +264,12 @@ def test_num_realizations_0_means_all(): ], ) def test_incorrect_variable_deprecation_warning(config, expected): - with warnings.catch_warnings(record=True) as all_warnings: - _ = AnalysisConfig.from_dict( + with pytest.warns(match=expected): + AnalysisConfig.from_dict( { ConfigKeys.ANALYSIS_SET_VAR: [config], } ) - assert expected in [str(warning.message) for warning in all_warnings] @pytest.mark.parametrize( diff --git a/tests/unit_tests/config/test_ensemble_config.py b/tests/unit_tests/config/test_ensemble_config.py index 2717bf3cb71..c1d3e017d2b 100644 --- a/tests/unit_tests/config/test_ensemble_config.py +++ b/tests/unit_tests/config/test_ensemble_config.py @@ -136,7 +136,7 @@ def test_ensemble_config_duplicate_node_names(): with pytest.raises( ConfigValidationError, match="GEN_KW and GEN_DATA contained duplicate name: Test_name", - ): + ), pytest.warns(match="The template file .* is empty"): EnsembleConfig.from_dict(config_dict=config_dict) diff --git a/tests/unit_tests/config/test_ert_config.py b/tests/unit_tests/config/test_ert_config.py index 8e5fcb7975d..933ee6c6bf0 100644 --- a/tests/unit_tests/config/test_ert_config.py +++ b/tests/unit_tests/config/test_ert_config.py @@ -444,7 +444,7 @@ def test_data_file_with_non_utf_8_character_gives_error_message(tmpdir): ConfigValidationError, match="Unsupported non UTF-8 character " f"'ΓΏ' found in file: {data_file_path!r}", - ): + ), pytest.warns(match="Failed to read NUM_CPU"): ErtConfig.from_file("config.ert")