Beispiel #1
0
def test_config_copy():
    cfg = Config(Schema_04())
    cp = cfg.copy()
    assert cfg.data == cp

    cp["updated"] = True
    assert cfg.data != cp
Beispiel #2
0
def test_config_mapping():
    cfg = Config(Schema_04())
    cp = cfg.copy()
    assert cfg.data == cp
    assert len(cfg) == len(cp)

    for key in cfg:
        assert cp[key] == cfg[key]
Beispiel #3
0
def test_apply_defaults_error():
    with pytest.raises(ApplyDefaultError):
        apply_defaults(Schema_04(), {"nested": 123})
Beispiel #4
0
def test_config_init():
    cfg = Config(Schema_04())

    # check internal cache
    data = cfg.data
    assert data == cfg.data
Beispiel #5
0
def test_get_nested():
    cfg = Config(Schema_04())
    data = cfg.data
    assert cfg.get_nested("nested") == {"int_attr_choices": 1}
    assert cfg.get_nested("nested.nonexistant") == None
Beispiel #6
0
def test_empty_config():
    cfg = Config(Schema_04())

    assert len(cfg)