def test_merge(tmp_path): """Test yaml merge with default settings.""" # default settings merged with itself yaml_str = "" ref_settings = Settings.from_local_file(DEFAULT_SETTINGS_FILE, DEFAULT_SETTINGS_FILE) _test_merge(tmp_path, yaml_str, ref_settings)
def test_alien_item(tmp_path, default_settings): """Test that an alien item in the yaml is ignored.""" yaml_str = "dummy: ''" settings_file = tmp_path / "settings.yaml" settings_file.write_text(yaml_str) settings = Settings.from_local_file(DEFAULT_SETTINGS_FILE, settings_file) assert settings == default_settings
def _test_merge(tmp_path, yaml_str, ref_settings): # helper function settings_file = tmp_path / "settings.yaml" settings_file.write_text(yaml_str) assert (Settings.from_local_file(DEFAULT_SETTINGS_FILE, settings_file) == ref_settings)
def default_settings(): """Fixture that returns a hand made default Settings object.""" return Settings(nproc=1, marks=set(), references=set(), tolerances={})
def test_yaml_validation(tmp_path, yaml_str): """Test yaml schema validation.""" settings_file = tmp_path / "settings.yaml" settings_file.write_text(yaml_str) with pytest.raises(ValidationError): Settings.from_local_file(DEFAULT_SETTINGS_FILE, settings_file)