def test_dict_merge_immutable(): """ensure dict merge is non-destructive/immutable.""" x1 = {'one': 1, 'two': 2} x1_cop = x1.copy() ir.dict_merge(x1, {'three': 3, 'two': None}) assert x1 == x1_cop ir.dict_merge({'ten': 10, 'one': '1'}, x1) assert x1 == x1_cop
def test_dict_merge_three(): new_dict = ir.dict_merge({ 'one': 1, 'two': 2 }, {'three': 3}, { 'four': 4, 'five': 5 }) assert new_dict == {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5}
def test_dict_merge_pair(): x1 = {'one': 1, 'two': '2'} x2 = {'two': 2, 'three': 3} assert ir.dict_merge(x1, x2) == {'one': 1, 'two': 2, 'three': 3}
def test_dict_merge_empty(): x1 = {'one': 1, 'two': 2} assert ir.dict_merge(x1, {}) == x1 assert ir.dict_merge({}, x1) == x1
def test_dict_merge_precedence(): x1 = {'one': 1, 'two': '2'} x2 = {'two': 2, 'three': 3} assert ir.dict_merge(x1, x2)['two'] == 2 assert ir.dict_merge(x2, x1)['two'] == '2'