Пример #1
0
def test_getting():
    nd = NestedDotDict()
    nd['a.b.c'] = 1
    nd['a.b.d'] = 2
    assert nd['a.b.c'] == 1
    assert nd['a.b.d'] == 2
    assert nd.to_dict() == {'a': {'b': {'c': 1, 'd': 2}}}
Пример #2
0
def test_simple():
    nd = NestedDotDict()
    nd['key'] = 0
    assert nd.to_dict() == {'key': 0}
Пример #3
0
def test_more_nesting():
    nd = NestedDotDict()
    nd['a.b.c.d.e.f'] = 1
    assert nd.to_dict() == {'a': {'b': {'c': {'d': {'e': {'f': 1}}}}}}
Пример #4
0
def test_longer_key_names():
    nd = NestedDotDict()
    nd['specialization.is.for.insects'] = 1
    assert nd.to_dict() == {'specialization': {'is': {'for': {'insects': 1}}}}
Пример #5
0
def test_field_creation():
    nd = NestedDotDict()
    nd['s'] = 1
    nd['a.b'] = 2
    nd['a.c'] = 3
    assert nd.to_dict() == {'s': 1, 'a': {'b': 2, 'c': 3}}