def test_list_multidimension(self):
        def construct_multidimension_list(lst_length):
            if lst_length == 1:
                return lst_length
            elif random.choice([False, True]):
                return [
                    lst_length,
                    [construct_multidimension_list(lst_length - 1)]
                ]
            else:
                return [
                    lst_length,
                    construct_multidimension_list(lst_length - 1)
                ]

        def is_valid(lst, length):
            if len(lst) != length:
                return False
            for idx, val in enumerate(lst):
                if length - idx != val:
                    return False
            return True

        for i in range(1, LIST_LENGTH):
            lst = construct_multidimension_list(i)
            flatten_lst = flatten(lst)
            err_msg = "multidimension flatten error."
            assert is_valid(flatten_lst, i), err_msg
 def test_complicated_nested_flatten_list(self):
     """
     Test flattenting of multiple stacked nested array using recursion function
     """
     result = flatten_list.flatten([[1], 2, [[3, 4], 5], [[[]]], [[[6]]], 7,
                                    8, []])
     print(result)
     self.assertEqual(result, [1, 2, 3, 4, 5, 6, 7, 8])
 def test_list_one_dimension(self):
     for i in range(1, LIST_LENGTH):
         lst = [val for val in range(i)]
         err_msg = "one dimension flatten error."
         assert lst == flatten(lst), err_msg
 def test_list_empty(self):
     err_msg = "empty list flatten error."
     assert flatten([]) == [], err_msg
 def test_value(self):
     err_msg = "value flatten error."
     assert flatten(123) == [123], err_msg
     assert flatten(123.123) == [123.123], err_msg