本文整理汇总了Python中misc.Misc.merge_dicts方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.merge_dicts方法的具体用法?Python Misc.merge_dicts怎么用?Python Misc.merge_dicts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Misc
的用法示例。
在下文中一共展示了Misc.merge_dicts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merge_dicts_overlapping_key_same_value
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import merge_dicts [as 别名]
def test_merge_dicts_overlapping_key_same_value(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'b': 2, 'd': 4}
should_be = {'a': 1, 'b': 2, 'd': 4}
result = Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertDictEqual(should_be, result)
示例2: test_merge_dicts_overlapping_key_different_value
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import merge_dicts [as 别名]
def test_merge_dicts_overlapping_key_different_value(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'b': 3, 'd': 4}
with self.assertRaises(Exception) as cm:
Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertTrue('Conflict at b' in cm.exception)
示例3: test_merge_dicts
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import merge_dicts [as 别名]
def test_merge_dicts(self):
dict_a = {'a': 1, 'b': 2}
dict_b = {'c': 3, 'd': 4}
should_be = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
result = Misc.merge_dicts(dict1=dict_a, dict2=dict_b)
self.assertDictEqual(should_be, result)