Ejemplo n.º 1
0
def test_bad_format(tmpdir, datadir):
    with pytest.raises(ValueError):
        load_config(datadir / "sequence.yaml", fmt="foo")

    with tmpdir.as_cwd():
        p = pathlib.Path("sequence.foo")
        p.symlink_to(datadir / "sequence.yaml")
        with pytest.raises(ValueError):
            load_config(p)
Ejemplo n.º 2
0
def test_no_extension(tmpdir, datadir, fmt):
    with tmpdir.as_cwd():
        p = pathlib.Path("sequence")
        p.symlink_to(datadir / f"sequence.{fmt}")
        with pytest.raises(ValueError):
            load_config(p, fmt=None)
        actual = load_config(p, fmt=fmt)
        expected = load_config(datadir / f"sequence.{fmt}")

        assert actual == expected
Ejemplo n.º 3
0
def test_load_config(datadir):
    config = {}
    for fmt in ("yaml", "toml"):
        config[fmt] = load_config(datadir / f"sequence.{fmt}", fmt=fmt)
    assert config["yaml"] == config["toml"]
Ejemplo n.º 4
0
def test_missing_file(tmpdir):
    with tmpdir.as_cwd():
        with pytest.raises(OSError):
            load_config("not-a-file.toml")
Ejemplo n.º 5
0
def test_guess_format(datadir, fmt):
    filepath = datadir / f"sequence.{fmt}"
    actual = load_config(filepath, fmt=None)
    expected = load_config(filepath, fmt=fmt)
    assert actual == expected