def test_update_with_lists(self): org = Json() org.a = [1, 2, {"a": "superman"}] someother = Json() someother.b = [{"b": 123}] org.update(someother) correct = {"a": [1, 2, {"a": "superman"}], "b": [{"b": 123}]} org.update(someother) self.assertDictEqual(org, correct) self.assertIsInstance(org.b[0], Json)
def test_update(self): old = Json() old.child.a = "old a" old.child.b = "old b" old.foo = "no dict" new = Json() new.child.b = "new b" new.child.c = "new c" new.foo.now_my_papa_is_a_dict = True old.update(new) reference = {"foo": {"now_my_papa_is_a_dict": True}, "child": {"c": "new c", "b": "new b"}} self.assertDictEqual(old, reference)