예제 #1
0
 def test_merge_two_levels(self):
     dct = {
         'a': {
             'A': 1,
             'AA': 2,
         },
         'b': {
             'B': 1,
             'BB': 2,
         },
     }
     overrides = {
         'a': {
             'AAA': 3,
         },
         'b': {
             'BBB': 3,
         },
     }
     _merge_dict(dct, overrides)
     self.assertEqual(
         dct, {
             'a': {
                 'A': 1,
                 'AA': 2,
                 'AAA': 3,
             },
             'b': {
                 'B': 1,
                 'BB': 2,
                 'BBB': 3,
             },
         })
예제 #2
0
 def test_merge_two_levels(self):
     """Test merging a dict with two levels."""
     dct = {
         'a': {
             'A': 1,
             'AA': 2,
         },
         'b': {
             'B': 1,
             'BB': 2,
         },
     }
     overrides = {
         'a': {
             'AAA': 3,
         },
         'b': {
             'BBB': 3,
         },
     }
     _merge_dict(dct, overrides)
     self.assertEqual(
         dct,
         {
             'a': {
                 'A': 1,
                 'AA': 2,
                 'AAA': 3,
             },
             'b': {
                 'B': 1,
                 'BB': 2,
                 'BBB': 3,
             },
         }
     )
예제 #3
0
 def test_merge_with_override(self):
     """Test merging a dict and overriding values."""
     dct = {'a': 1}
     _merge_dict(dct, {'a': 0, 'b': 2})
     self.assertEqual(dct, {'a': 0, 'b': 2})
예제 #4
0
 def test_merge_flat(self):
     """Test merging a flat dict."""
     dct = {'c': 3}
     _merge_dict(dct, {'a': 1, 'b': 2})
     self.assertEqual(dct, {'a': 1, 'b': 2, 'c': 3})
예제 #5
0
 def test_merge_into_empty_dict(self):
     """Test merging into an empty dict."""
     dct = {}
     _merge_dict(dct, {'a': 1, 'b': 2})
     self.assertEqual(dct, {'a': 1, 'b': 2})
예제 #6
0
 def test_merge_with_override(self):
     dct = {'a': 1}
     _merge_dict(dct, {'a': 0, 'b': 2})
     self.assertEqual(dct, {'a': 0, 'b': 2})
예제 #7
0
 def test_merge_flat(self):
     dct = {'c': 3}
     _merge_dict(dct, {'a': 1, 'b': 2})
     self.assertEqual(dct, {'a': 1, 'b': 2, 'c': 3})
예제 #8
0
 def test_merge_into_empty_dict(self):
     dct = {}
     _merge_dict(dct, {'a': 1, 'b': 2})
     self.assertEqual(dct, {'a': 1, 'b': 2})