Example #1
0
def test_dictconfig():
    conf = DictConfig(
        {"TEST": "value", "PREFIX_ONE": "foo", "PREFIX_TWO": "bar"}
    )
    assert conf.get("FOO") is NOT_PROVIDED
    assert dict(conf.iterprefixed("NOPREFIX_")) == {}
    assert conf.get("TEST") == "value"
    assert dict(conf.iterprefixed("PREFIX_")) == {
        "PREFIX_ONE": "foo",
        "PREFIX_TWO": "bar",
    }
Example #2
0
def test_dictconfig():
    conf = DictConfig({
        "TEST": "value",
        "PREFIX_ONE": "foo",
        "PREFIX_TWO": "bar"
    })
    assert conf.get("FOO") is NOT_PROVIDED
    assert dict(conf.iterprefixed("NOPREFIX_")) == {}
    assert conf.get("TEST") == "value"
    assert dict(conf.iterprefixed("PREFIX_")) == {
        "PREFIX_ONE": "foo",
        "PREFIX_TWO": "bar",
    }
Example #3
0
def test_dict_iter_config():
    conf = DictConfig(
        {
            "TEST_KEY_1": 1,
            "TEST_KEY_2": 2,
            "TEST_FOO_3": 3,
            "TEST_KEX_1": 1,
            "TEST_KEY_3": 3,
            "TEST_BAR_1": 1,
        },
        prefix="TEST_",
    )

    items = conf.iterprefixed("KEY_")
    assert sorted(items) == [("KEY_1", 1), ("KEY_2", 2), ("KEY_3", 3)]