예제 #1
0
def test_defaults():
    c = Config(in_memory=True, defaults={'foo': 1})
    assert c.get('foo') == 1
    c['foo'] = 2
    assert c.get('foo') == 2
    del c['foo']
    assert c.get('foo') == 1
예제 #2
0
def test_get():
    with tempfile.TemporaryDirectory() as tempdir:
        c = Config(config_dir=tempdir)
        assert c.get('foo') is None
        assert c.get('foo', 1) == 1
        c['foo'] = 2
        assert c.get('foo') == 2
예제 #3
0
def test_init_load():
    with tempfile.TemporaryDirectory() as tempdir:
        c = Config(config_dir=tempdir)
        c['foo'] = 1
        c.save()
        c = Config(config_dir=tempdir)
        assert c.get('foo') == 1
예제 #4
0
def test_initial():
    c = Config(in_memory=True, initial={'foo': 1})
    assert c.get('foo') == 1