def test_expando_to_dict_with_update(): d1 = {"a": 123, "b": "abc"} x = Expando(d1) d = {"b": {"c": 456, "d": {"e": "abc"}}, "f": "lmn"} x.update(d) expected = {} expected.update(d1) expected.update(d) assert expected == x.to_dict() d2 = {"a": 789, "f": "opq"} y = Expando(d2) x.update(y) expected.update(d2) assert expected == x.to_dict()
def test_expando_update(): d1 = {"a": 123, "b": "abc"} x = Expando(d1) assert x.a == d1['a'] assert x.b == d1['b'] d = {"b": {"c": 456, "d": {"e": "abc"}}, "f": "lmn"} x.update(d) assert x.a == d1['a'] assert x.b.c == d['b']['c'] assert x.b.d.e == d['b']['d']['e'] assert x.f == d["f"] d2 = {"a": 789, "f": "opq"} y = Expando(d2) x.update(y) assert x.a == 789 assert x.f == "opq"