Exemplo n.º 1
0
    def test_my_sum__when_strings__expect_value_exception(self):
        numbers = ['a', 'b', 'c']
        with self.assertRaises(ValueError) as context:
            my_sum(numbers)

        expected_message = '`numbers` should be ints or floats'
        actual_message = context.exception.args[0]

        self.assertEqual(expected_message, actual_message)
Exemplo n.º 2
0
 def test_my_sum__when_strings__expect_value_exception(self):
     numbers = ['a', 'b', 'c']
     with self.assertRaises(ValueError) as context:
         my_sum(numbers)
Exemplo n.º 3
0
    def test_my_sum__when_floats__expect_to_be_equal(self):
        numbers = [1.0, 2.0, 3.0, 4.0]
        actual_result = my_sum(numbers)
        expected_result = 10.0

        self.assertEqual(expected_result, actual_result)
Exemplo n.º 4
0
    def test_my_sum__when_ints__expect_to_be_equal(self):
        numbers = [1, 2, 3, 4]
        actual_result = my_sum(numbers)
        expected_result = 10

        self.assertEqual(expected_result, actual_result)