Ejemplo n.º 1
0
def test_get(config_dict):
    node = ConfigNode(config_dict)
    assert node.key1 == 1
    with pytest.raises(AttributeError):
        node.nokey

    assert node.get("key1") == 1
    with pytest.raises(AttributeError):
        node.get("nokey")

    assert node.get("key2.key3") == 3
Ejemplo n.º 2
0
def test_iteration(config_dict):
    config = ConfigNode(config_dict)
    for iter_key, key, value, item in zip(config, config.keys(),
                                          config.values(), config.items()):
        item_key, item_value = item
        assert iter_key == key
        assert item_key == key
        assert item_value == value
        assert config.get(key) == value