예제 #1
0
 def test_nested_dict(self):
     self.assertEqual(
         apply_recursively(
             [{
                 'a': 1,
                 'b': [2, 3],
                 'c': {
                     'd': 4,
                     'e': None
                 }
             }, 5],
             lambda n: n + 1,
         ),
         [{
             'a': 2,
             'b': [3, 4],
             'c': {
                 'd': 5,
                 'e': None
             }
         }, 6],
     )
예제 #2
0
 def test_nested_dict(self):
     self.assertEqual(
         apply_recursively([{'a': 1, 'b': [2,3], 'c': { 'd': 4, 'e': None }}, 5], lambda n: n+1),
         [{'a': 2, 'b': [3,4], 'c': { 'd': 5, 'e': None }}, 6]
     )
예제 #3
0
 def test_nested_tuple(self):
     self.assertEqual(
         apply_recursively([(1,2),(3,4)], lambda n: n+1),
         [[2,3],[4,5]]
     )
예제 #4
0
 def test_list(self):
     self.assertEqual(
         apply_recursively([1,2,3], lambda n: n+1),
         [2,3,4]
     )
예제 #5
0
 def test_none(self):
     self.assertEqual(
         apply_recursively(None, lambda n: n+1),
         None
     )
예제 #6
0
 def test_nested_tuple(self):
     self.assertEqual(
         apply_recursively([(1, 2), (3, 4)], lambda n: n + 1),
         [[2, 3], [4, 5]],
     )
예제 #7
0
 def test_list(self):
     self.assertEqual(apply_recursively([1, 2, 3], lambda n: n + 1),
                      [2, 3, 4])
예제 #8
0
 def test_none(self):
     self.assertEqual(apply_recursively(None, lambda n: n + 1), None)