Ejemplo n.º 1
0
 def test_changed_on_delitem(self, m):
     sample = {"a": 1, "b": 2}
     d = types.MutableDict(sample)
     del d["b"]
     self.assertEqual({"a": 1}, d)
     self.assertEqual(1, m.call_count)
Ejemplo n.º 2
0
 def test_coerce_mutable_dict(self):
     sample = {"a": 1, "b": 2}
     sample_md = types.MutableDict(sample)
     md = types.MutableDict.coerce("test", sample_md)
     self.assertEqual(sample, md)
     self.assertIs(sample_md, md)
Ejemplo n.º 3
0
 def test_changed_on_update(self, m):
     sample = {"a": 1, "b": 2}
     d = types.MutableDict(sample)
     d.update({"b": 3})
     self.assertEqual({"a": 1, "b": 3}, d)
     self.assertEqual(1, m.call_count)
Ejemplo n.º 4
0
 def test_creation(self):
     sample = {"a": 1, "b": 2}
     d = types.MutableDict(sample)
     self.assertEqual(sample, d)