def test_find_with_no_result_and_default(self):
     i = {
         'a': 1,
         'b': 2,
         'c': 3,
         'd': None,
     }
     o = _find(i, ['x', 'y', 'z'], 5)
     self.assertEqual(o, 5)
 def test_find_with_single_result(self):
     i = {
         'a': 1,
         'b': 2,
         'c': 3,
         'd': None,
     }
     o = _find(i, ['x', 'y', 'b', 'z'], 5)
     self.assertEqual(o, 2)
 def test_find_with_multiple_results(self):
     i = {
         'a': 1,
         'b': 2,
         'c': 3,
         'd': None,
     }
     o = _find(i, ['a', 'x', 'b', 'y'])
     self.assertEqual(o, 1)
Example #4
0
 def find(self, keys, default=None):
     """
     Return the first match searching for the given keys.
     If no result found, default value is returned.
     """
     return _find(self, keys, default)