Ejemplo n.º 1
0
def test_as_dict_content_conv_depth():
    dct = {'a': 10, 'b': collections.OrderedDict([('x', 1), ('y', collections.OrderedDict([('r', 222)])), ('z', 3)]), 'c': 3}
    stddct = dictutils.as_dict(dct, depth=1)
    assert stddct == dct
    assert stddct is not dct
    assert type(stddct['b']) == dict
    assert type(stddct['b']['y']) == collections.OrderedDict
Ejemplo n.º 2
0
def test_as_dict_content_conv_depth():
    dct = {'a': 10, 'b': collections.OrderedDict([('x', 1), ('y', collections.OrderedDict([('r', 222)])), ('z', 3)]), 'c': 3}
    stddct = dictutils.as_dict(dct, depth=1)
    assert stddct == dct
    assert stddct is not dct
    assert type(stddct['b']) == dict
    assert type(stddct['b']['y']) == collections.OrderedDict
Ejemplo n.º 3
0
def test_Config_defaults_external(extdefaults):
    edcopy = as_dict(extdefaults, depth=-1, dict_class=dict)
    config = Config(defaults=extdefaults)
    assert config.has_section('sub')
    assert config['sub']['f22'] == 2.2
    assert not config['sub'].has_section('sse')
    with pytest.raises(KeyError) as exc_info:
        config['sub']['sse']['xx'] = 18
    assert str(exc_info.value) == "'sse'"
    assert not config['sub'].has_section('sse')
    assert config['sub'].has_section('ssf')
    assert len(config['sub']['ssf']) == 0
    assert config['sub']['ssf']['f44'] == 4.4
    config['sub']['ssf']['xx'] = 19
    del config['sub']
    assert config.has_section('sub')
    assert config['sub'].has_section('ssf')
    assert config['sub']['ssf'].has_option('f44')
    assert config['sub']['ssf']['f44'] == 4.4
    edcopy2 = as_dict(extdefaults, depth=-1, dict_class=dict)
    assert edcopy == edcopy2
Ejemplo n.º 4
0
def test_Config_defaults_external(extdefaults):
    edcopy = as_dict(extdefaults, depth=-1, dict_class=dict)
    config = Config(defaults=extdefaults)
    assert config.has_section('sub')
    assert config['sub']['f22'] == 2.2
    assert not config['sub'].has_section('sse')
    with pytest.raises(KeyError) as exc_info:
        config['sub']['sse']['xx'] = 18
    assert str(exc_info.value) == "'sse'"
    assert not config['sub'].has_section('sse')
    assert config['sub'].has_section('ssf')
    assert len(config['sub']['ssf']) == 0
    assert config['sub']['ssf']['f44'] == 4.4
    config['sub']['ssf']['xx'] = 19
    del config['sub']
    assert config.has_section('sub')
    assert config['sub'].has_section('ssf')
    assert config['sub']['ssf'].has_option('f44')
    assert config['sub']['ssf']['f44'] == 4.4
    edcopy2 = as_dict(extdefaults, depth=-1, dict_class=dict)
    assert edcopy == edcopy2
Ejemplo n.º 5
0
def test_as_dict_content_class():
    dct = {'a': 10, 'b': {'x': 1, 'y': {'r': 222}, 'z': 3}, 'c': 3}
    stddct = dictutils.as_dict(dct, dict_class=collections.OrderedDict)
    assert type(stddct) == collections.OrderedDict
    assert type(stddct['b']) == collections.OrderedDict
    assert type(stddct['b']['y']) == collections.OrderedDict
Ejemplo n.º 6
0
def test_as_dict_content():
    dct = {'a': 10, 'b': {'x': 1, 'y': {'r': 222}, 'z': 3}, 'c': 3}
    stddct = dictutils.as_dict(dct)
    assert stddct == dct
    assert stddct is not dct
Ejemplo n.º 7
0
def test_as_dict():
    dct = {}
    stddct = dictutils.as_dict(dct)
    assert stddct == dct
    assert stddct is not dct
Ejemplo n.º 8
0
def test_as_dict_content_class():
    dct = {'a': 10, 'b': {'x': 1, 'y': {'r': 222}, 'z': 3}, 'c': 3}
    stddct = dictutils.as_dict(dct, dict_class=collections.OrderedDict)
    assert type(stddct) == collections.OrderedDict
    assert type(stddct['b']) == collections.OrderedDict
    assert type(stddct['b']['y']) == collections.OrderedDict
Ejemplo n.º 9
0
def test_as_dict_content():
    dct = {'a': 10, 'b': {'x': 1, 'y': {'r': 222}, 'z': 3}, 'c': 3}
    stddct = dictutils.as_dict(dct)
    assert stddct == dct
    assert stddct is not dct
Ejemplo n.º 10
0
def test_as_dict():
    dct = {}
    stddct = dictutils.as_dict(dct)
    assert stddct == dct
    assert stddct is not dct