예제 #1
0
    def test_triangle_area(self):

        # Test area function with some example data
        self.assertEqual(12, triangle_math.area(6, 4))

        # Test with floats
        self.assertAlmostEqual(17.79875, triangle_math.area(7.25, 4.91))
    def test_triangle_area(self):

        #Test area function with some example data
        self.assertEqual(
            12, triangle_math.area(6, 4)
        )  #first number is expected result, second numbers are what you're sending to the area function

        #Test with floats
        self.assertAlmostEqual(17.79875, triangle_math.area(
            7.25, 4.91))  #the same as before, but with float numbers
예제 #3
0
    def test_triangle_with_negative_input(self):

        with self.assertRaises(ValueError):
            triangle_math.area(9, -10)

        with self.assertRaises(ValueError):
            triangle_math.area(-9, 10)

        with self.assertRaises(ValueError):
            triangle_math.area(-9, -10)
예제 #4
0
 def test_floating_point(self):
     self.assertAlmostEqual(17.79875, triangle_math.area(7.25, 4.91))
예제 #5
0
 def test_triangle_area(self):
     self.assertEqual(12, triangle_math.area(6, 4))
예제 #6
0
 def test_raises_exception_for_negative_params(self):
     # Assert that the code raises a ValueError
     # no ValueError = test fail.
     with self.assertRaises(ValueError):
         triangle_math.area(-10, 9)