Exemplo n.º 1
0
 def test_lazy_get(self):
     d = LazyDict({'a': 1, 'b': 2})
     d.set_stub('d', lambda x:x)        
     self.assertIs(d.get('c'), None)
     self.assertEqual(d.get('c', 3), 3)
     self.assertEqual(d.get('a'), 1)
     self.assertEqual(d.get('a', 3), 1)
     self.assertEqual(d.get('d'), 'd')
     self.assertEqual(d.get('d', 3), 'd')
     self.assertRaises(TypeError, d.get)
     self.assertRaises(TypeError, d.get, None, None, None)
Exemplo n.º 2
0
 def test_get(self):
     d = LazyDict()
     self.assertIs(d.get('c'), None)
     self.assertEqual(d.get('c', 3), 3)
     d = LazyDict({'a': 1, 'b': 2})
     self.assertIs(d.get('c'), None)
     self.assertEqual(d.get('c', 3), 3)
     self.assertEqual(d.get('a'), 1)
     self.assertEqual(d.get('a', 3), 1)
     self.assertRaises(TypeError, d.get)
     self.assertRaises(TypeError, d.get, None, None, None)