Beispiel #1
0
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)
Beispiel #2
0
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
Beispiel #3
0
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)
Beispiel #4
0
def default_settings():
    """Fixture that returns a hand made default Settings object."""
    return Settings(nproc=1, marks=set(), references=set(), tolerances={})
Beispiel #5
0
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)