Example #1
0
 def test_destructure_dict_list_short_complete(self):
     dict_list = [{"a": 0}, {"b": 1, "c": 2}]
     result_dict_list = destructure_dict_list([1, 1], dict_list)
     self.assertEqual(len(result_dict_list), 2)
     self.assertEqual(len(result_dict_list[0]), 1)
     self.assertEqual(len(result_dict_list[1]), 1)
     self.assertEqual(result_dict_list[0][0], {"a": 0})
     self.assertEqual(result_dict_list[1][0], {"b": 1, "c": 2})
Example #2
0
 def test_destructure_dict_list_short_incomplete(self):
     dict_list = [{"a": 0}, {"b": 1, "c": 2, "d": 3}, {"e": 4, "f": 5}]
     result_dict_list = destructure_dict_list([1, 1, 0], dict_list)
     self.assertEqual(len(result_dict_list), 3)
     self.assertEqual(len(result_dict_list[0]), 1)
     self.assertEqual(len(result_dict_list[1]), 1)
     self.assertEqual(len(result_dict_list[2]), 0)
     self.assertEqual(result_dict_list[0][0], {"a": 0})
     self.assertEqual(result_dict_list[1][0], {"b": 1, "c": 2, "d": 3})
Example #3
0
 def test_destructure_dict_list_long2(self):
     dict_list = [{"a": 0} for i in range(2000)]
     length_list = [1, 2, 3, 4] * 100
     result_dict_list = destructure_dict_list(length_list, dict_list)
     self.assertEqual(len(result_dict_list), len(length_list))
     for i in range(len(length_list)):
         self.assertEqual(len(result_dict_list[i]), length_list[i])
     for sublist in result_dict_list:
         for tens in sublist:
             self.assertEqual(tens, {"a": 0})
Example #4
0
 def test_destructure_dict_list_long1(self):
     dict_list = [{"a": 0} for i in range(1000)]
     result_dict_list = destructure_dict_list([100, 200, 300, 400], dict_list)
     self.assertEqual(len(result_dict_list), 4)
     self.assertEqual(len(result_dict_list[0]), 100)
     self.assertEqual(len(result_dict_list[1]), 200)
     self.assertEqual(len(result_dict_list[2]), 300)
     self.assertEqual(len(result_dict_list[3]), 400)
     for sublist in result_dict_list:
         for tens in sublist:
             self.assertEqual(tens, {"a": 0})
Example #5
0
 def test_destructure_dict_list_empty(self):
     dict_list = [{"a": 0}]
     result_dict_list = destructure_dict_list([], dict_list)
     self.assertEqual(len(result_dict_list), 0)