Пример #1
0
def test_config_should_proxy_dict():
    config = Config({'key': 'value', 'other': {'sub': 'subvalue'}})
    assert config.key == 'value'
    assert config['key'] == 'value'
    assert config.get('key') == 'value'
    assert config.get('missing', 'default') == 'default'
    assert config.other.sub == 'subvalue'
Пример #2
0
def test_config_as_kwargs():
    config = Config()
    config.foo = 'bar'

    def foo(**kwargs):
        return kwargs

    assert foo(**config) == config
Пример #3
0
def test_config_setattr():
    config = Config()
    config.foo = 'bar'
    assert config.foo == 'bar'
Пример #4
0
def test_config_str():
    config = Config()
    config.foo = 'bar'
    assert f'foo{config.foo}baz' == 'foobarbaz'
Пример #5
0
def test_config_should_swallow_missing_keys():
    config = Config()
    assert not config
    assert not config.missing
    assert not config.missing.again