Пример #1
0
def test_dotdict_merge():
    a = DotDict()
    b = {1: {2: 2, 3: 3, 4: {5: "fin."}}}
    a.update(b)
    assert a == b
    b[1][2] = 5
    assert a != b

    a.update({1: {4: {5: "new.", 6: "fin."}, 2: "x"}})
    assert a == {1: {2: "x", 3: 3, 4: {5: "new.", 6: "fin."}}}
Пример #2
0
def test_dotdict_keeptype():
    a = DotDict()
    a.update({"nr": {"upper": 1}})
    assert a.nr.upper == 1

    assert "{nr.upper}".format(**a) == "1"