Ejemplo n.º 1
0
 def test_ddict_attribute(self):
     d = ddict.ddict({'a':1})
     self.assertEqual(d['a'], 1)
     self.assertEqual(d.a, 1)
     self.assertRaises(KeyError, lambda: d['b'])
     self.assertRaises(KeyError, lambda: d.b)
     def assign():
         d.b = 4
     self.assertRaises(KeyError, assign)
     self.assertRaises(KeyError, lambda: d.b)
     d['b'] = 3
     self.assertEqual(d['b'], 3)
     self.assertEqual(d.b, 3)
     d.b = 4
     self.assertEqual(d['b'], 4)
     self.assertEqual(d.b, 4)
Ejemplo n.º 2
0
 def test_ddict_empty(self):
     d = ddict.ddict()
     self.assertEqual(not d, True)
     d = ddict.ddict({})
     self.assertEqual(not d, True)