def test_copy(self): s1 = State(a=PliableDict(x=1)) s2 = s1.copy() self.assertEqual(s1, s2) s1.a.x = 2 self.assertNotEqual(s1, s2) self.assertNotEqual(id(s1), id(s2)) self.assertEqual(s1.a.x, 2) self.assertEqual(s2.a.x, 1)
def test_getter(self): d = PliableDict(x=1) self.assertEqual(d.x, 1) self.assertEqual(d.y, None)
def test_setter(self): d = PliableDict() d.x = 1 self.assertDictEqual(d, {'x': 1})
def test_construction(self): self.assertDictEqual(PliableDict(), {}) self.assertDictEqual(PliableDict(x=1), {'x': 1}) self.assertDictEqual(PliableDict(**{'x': 1}), {'x': 1}) self.assertDictEqual(PliableDict({'x': 1, 'y': 2}), {'x': 1, 'y': 2})