Beispiel #1
0
 def test_type_match(self):
     self.assertTrue(merge_results.TypeMatch(types.DictType)(dict()))
     self.assertFalse(
         merge_results.TypeMatch(types.ListType, types.TupleType)(dict()))
     self.assertTrue(
         merge_results.TypeMatch(types.ListType, types.TupleType)(list()))
     self.assertTrue(
         merge_results.TypeMatch(types.ListType, types.TupleType)(tuple()))
Beispiel #2
0
 def test_custom_match_on_obj_type(self):
     m = merge_results.JSONMerger()
     m.add_helper(
         merge_results.TypeMatch(int),
         lambda o, name=None: sum(o))
     self.assertDictEqual({'a': 3}, m.merge([{'a': 1}, {'a': 2}]))
     self.assertDictEqual({'b': 3}, m.merge([{'b': 1}, {'b': 2}]))
 def test_type_match(self):
     self.assertTrue(merge_results.TypeMatch(dict)(dict()))
     self.assertFalse(merge_results.TypeMatch(list, tuple)(dict()))
     self.assertTrue(merge_results.TypeMatch(list, tuple)(list()))
     self.assertTrue(merge_results.TypeMatch(list, tuple)(tuple()))