def test_returns_int(self):
        """
        Test count_above to make sure it returns an int.
        """
        return_type = type(count_above(1, 2))
        self.assertEqual(return_type, int, "count_above should return type " +
                         "int, but instead returned type {}.".format(
                             return_type))

        return_type = type(count_above([1], 2))
        self.assertEqual(return_type, int, "count_above should return type " +
                         "int, but instead returned type {}.".format(
                             return_type))
    def test_count_even(self, list_values, list_indices, n):
        """
        Test the submitted count_even against a randomly generated list.
        """

        # Gather all of the even values
        expected = 0
        for i in list_values:
            if i > n:
                expected += 1

        # Create up to 2 levels of nesting for the values in list_values, where
        # the indices we turn into sublists are contained in
        # nesting_indices_1 and nesting_indices_2
        nesting_indices_1 = list_indices[:len(list_indices)//2]
        nesting_indices_2 = list_indices[len(list_indices)//2:]
        nesting_indices_1.sort()
        nesting_indices_2.sort()

        obj = create_nested_list(list_values, [nesting_indices_1,
                                               nesting_indices_2])

        # Ignoring the order of the values, in case students have an
        # out-of-order version for some reason.
        actual = count_above(obj, n)

        self.assertEqual(actual, expected,
                         ("Using count_above with n = {} on {} returned" +
                          " {} instead of {}.").format(n, obj, actual, expected)
                         )
 def test_one_nested_sublist_and_integers(self):
     """
     Test count_above on a list with at most one level of nested sublists in
     it mixed with integers.
     """
     self.assertEqual(count_above([[2], 3, [4]], 2), 2,
                      "count_above should return the number of integers " +
                      "> n in nested sublists and in the list passed " +
                      "in.")
 def test_one_nested_sublist(self):
     """
     Test count_above on a list with only one sublist in it.
     """
     self.assertEqual(count_above([[2]], 1), 1, "count_above should return" +
                      " the number of integers > n in nested sublists.")
 def test_larger_integer(self):
     """
     Test count_above on an integer > n
     """
     self.assertEqual(count_above(2, 1), 1, "count_above should return 1 " +
                      "when given an integer > n.")
 def test_smaller_integer(self):
     """
     Test count_above on an integer <= n.
     """
     self.assertEqual(count_above(2, 2), 0, "count_above should return 0 " +
                      "when passed an integer <= n.")