コード例 #1
0
 def test_merge_dicts_copy(self):
     d = {'a': 1, 'b': 1}
     self.assertDictEqual(transformations.merge_dicts(d, copy=True), d)
     self.assertDictEqual(transformations.merge_dicts(d, d, copy=True), d)
     self.assertDictEqual(transformations.merge_dicts(d, {'a': 2}, copy=True), {'a': 2, 'b':1})
     self.assertDictEqual(d, {'a': 1, 'b': 1})
コード例 #2
0
 def test_merge_dicts_no_copy(self):
     d = {'a': 1, 'b': 1}
     self.assertDictEqual(transformations.merge_dicts(d, copy=False), d)
     self.assertDictEqual(transformations.merge_dicts(d, d, copy=False), d)
     self.assertDictEqual(transformations.merge_dicts(d, {'a': 2}, copy=False), {'a': 2, 'b':1})
     self.assertEquals(d['a'], 2)
コード例 #3
0
 def test_merge_dicts_basics(self):
     self.assertDictEqual(transformations.merge_dicts({'a': 1}), {'a': 1})
     self.assertDictEqual(transformations.merge_dicts({'a': 1}, {'a': 2}), {'a': 2})
     self.assertDictEqual(transformations.merge_dicts(
         {'a': 1, 'b': 1}, {'a': 2, 'c': 1}), {'a': 2, 'b': 1, 'c': 1})