def test_assign1(self): a = {} b = GreedyAccess(a) b.c = "test1" b.d.e = "test2" b.f.g.h = "test3" b.f.i = "test4" b.k["l.m.n"] = "test5" expected = { "c": "test1", "d": { "e": "test2" }, "f": { "g": { "h": "test3" }, "i": "test4" }, "k": { "l": { "m": { "n": "test5" } } } } self.assertEqual(a, expected)
def test_assign4(self): # IMPOTENT ASSIGNMENTS DO NOTHING a = {"c": {"d": {}}} b = GreedyAccess(a) b.c.d = None expected = {"c": {}} self.assertEqual(a, expected) a = {"c": {"d": {}}} b = GreedyAccess(a) b.c = None expected = {} self.assertEqual(a, expected)
def test_assign3(self): # IMPOTENT ASSIGNMENTS DO NOTHING a = {} b = GreedyAccess(a) b.c = None expected = {} self.assertEqual(a, expected) b.c.d = None expected = {} self.assertEqual(a, expected) b["c.d"] = None expected = {} self.assertEqual(a, expected) b.c.d.e = None expected = {} self.assertEqual(a, expected) b.c["d.e"] = None expected = {} self.assertEqual(a, expected)