예제 #1
0
 def test_depth_1(self):
     self.assertEqual(flatten_dictionary({
         'a': 1,
         'b': 2,
         'c': 3
     }), {
         'a': 1,
         'b': 2,
         'c': 3
     })
예제 #2
0
 def test_depth_2_no_crumbs(self):
     self.assertEqual(
         flatten_dictionary({
             'a': 1,
             'b': {
                 'd': 4,
                 'e': 5
             },
             'c': 3
         }, False), {
             'a': 1,
             'd': 4,
             'e': 5,
             'c': 3
         })
예제 #3
0
 def test_depth_2(self):
     self.assertEqual(
         flatten_dictionary({
             'a': 1,
             'b': {
                 'd': 4,
                 'e': 5
             },
             'c': 3
         }), {
             'a': 1,
             'b_d': 4,
             'b_e': 5,
             'c': 3
         })
예제 #4
0
 def test_depth_3(self):
     self.assertEqual(
         flatten_dictionary({
             'a': 1,
             'b': {
                 'd': 4,
                 'e': {
                     'f': 6,
                     'g': 7
                 }
             },
             'c': {
                 'h': 8
             }
         }), {
             'a': 1,
             'b_d': 4,
             'b_e_f': 6,
             'b_e_g': 7,
             'c_h': 8
         })
예제 #5
0
 def test_depth_3_no_crumbs(self):
     self.assertEqual(
         flatten_dictionary(
             {
                 'a': 1,
                 'b': {
                     'a': 1,
                     'd': 4,
                     'e': {
                         'f': 6,
                         'd': 7
                     }
                 },
                 'c': {
                     'h': 8
                 }
             }, False), {
                 'a': [1, 1],
                 'd': [4, 7],
                 'f': 6,
                 'h': 8
             })
예제 #6
0
 def test_depth_3_no_crumbs(self):
     self.assertEqual(flatten_dictionary({'a': 1, 'b': {'a': 1, 'd': 4, 'e': {'f': 6, 'd': 7}}, 'c': {'h': 8}}),
                      {'a': [1, 1], 'd': [5, 7], 'f': 6, 'h': 8})
예제 #7
0
 def test_depth_2_no_crumbs(self):
     self.assertEqual(flatten_dictionary({'a': 1, 'b': {'d': 4, 'e': 5}, 'c': 3}),
                      {'a': 1, 'd': 5, 'e': 5, 'c': 3})
예제 #8
0
 def test_depth_3(self):
     self.assertEqual(flatten_dictionary({'a': 1, 'b': {'d': 4, 'e': {'f': 6, 'g': 7}}, 'c': {'h': 8}}),
                      {'a': 1, 'b_d': 5, 'b_e_f': 6, 'b_e_g': 7, 'c_h': 8})
예제 #9
0
 def test_depth_1(self):
     self.assertEqual(flatten_dictionary({'a': 1, 'b': 2, 'c': 3}), {'a': 1, 'b': 2, 'c': 3})