예제 #1
0
def test_Config_copy(defaultsvalue):
    config = Config(defaults=defaultsvalue)
    config['a'] = 10
    config.set_defaults(b=20)
    config2 = config.copy()
    assert config2 == config
    assert isinstance(config2, Config)
예제 #2
0
def test_Config_copy_deep():
    config = Config()
    config['a'] = 10
    config['sub'] = {'x': 10, 'y': 20, 'z': {'w': 30, 't': 40}}
    s = config.to_string(fmt="zirkon")
    # config.dump()
    # print()
    config2 = config.copy()
    del config2["a"]
    del config2["sub"]["y"]
    del config2["sub"]["z"]
    # config.dump()
    s2 = config.to_string(fmt="zirkon")
    assert s == s2
예제 #3
0
def test_Config_defaults_copy():
    config = Config(defaults=True)
    config['d'] = 11
    config['e'] = 12
    config.set_defaults(a={}, b=5, c={'x': 7}, d=8)
    config2 = config.copy()
    assert not config2.has_section('a')
    assert config2.has_option('b')
    assert config2['b'] == 5
    assert config2.has_section('c')
    assert len(config2['c']) == 0
    assert config2['c']['x'] == 7
    assert config2.has_option('d')
    assert config2['d'] == 11
    assert config2.has_option('e')
    assert config2['e'] == 12
예제 #4
0
def test_Config_defaults_copy():
    config = Config(defaults=True)
    config['d'] = 11
    config['e'] = 12
    config.set_defaults(a={}, b=5, c={'x': 7}, d=8)
    config2 = config.copy()
    assert not config2.has_section('a')
    assert config2.has_option('b')
    assert config2['b'] == 5
    assert config2.has_section('c')
    assert len(config2['c']) == 0
    assert config2['c']['x'] == 7
    assert config2.has_option('d')
    assert config2['d'] == 11
    assert config2.has_option('e')
    assert config2['e'] == 12
예제 #5
0
def test_Config_copy(defaultsvalue):
    config = Config(defaults=defaultsvalue)
    config['a'] = 10
    config.set_defaults(b=20)
    config2 = config.copy()
    assert config2 == config