コード例 #1
0
    def test_get_smallest_number_with_negative(self):
        try:
            data = [1, 2, 4, 4, -3, 3, 1, -1]
            original_data = data[:]

            result = exercises.get_smallest_number(data)

            self.assertEqual(-3, result)
            self.assertListEqual(original_data, data,
                                 ORIGINAL_ARGUMENTS_MODIFIED)
        except ForbiddenError as err:
            self.assertEqual("You CANNOT use `min` built-in method.",
                             err.message)
コード例 #2
0
    def test_get_smallest_number_with_floats(self):
        try:
            data = [4, 500, 250, 499.9, 4.1, 3.9]
            original_data = data[:]

            result = exercises.get_smallest_number(data)

            self.assertEqual(3.9, result)
            self.assertListEqual(original_data, data,
                                 ORIGINAL_ARGUMENTS_MODIFIED)
        except ForbiddenError as err:
            self.assertEqual("You CANNOT use `min` built-in method.",
                             err.message)