コード例 #1
0
 def test_input(self):
     # This function will check whether all the data points are present in correct format or not
     with self.assertRaises(ValueError):
         classify_triangle("Akshay", 1, 2)
     with self.assertRaises(ValueError):
         classify_triangle("a", "b", "c")
     with self.assertRaises(ValueError):
         classify_triangle("A", "B", "C")
コード例 #2
0
 def test_not_triangle(self):
     # This function will tell us whether this is triangle or not
     self.assertEqual(classify_triangle(15.5, 15.5, -15.5), 'This is not a triangle',
                      '15.5, 15.5, -15.5 is not a triangle')
     self.assertEqual(classify_triangle(0, 0, 0), 'This is not a triangle', '0, 0, 0 is not a triangle')
コード例 #3
0
 def test_scalene_right(self):
     # This function will tell us whether the triangle is scalene and right triangle or not
     self.assertEqual(classify_triangle(3, 4, 5), 'Right and Scalene Triangle',
                      '3, 4, 5 is a scalene and right Triangle')
コード例 #4
0
 def test_isosceles_right(self):
     # This function will tell us whether the triangle is isosceles and right triangle or not
     self.assertEqual(classify_triangle(2, 2, 2.828), 'Right and Isosceles Triangle')
コード例 #5
0
 def test_scalene(self):
     # This function will tell us whether the triangle is scalene triangle or not
     self.assertEqual(classify_triangle(10, 20, 12), 'Scalene', '10, 20, 12 is a scalene triangle')
     self.assertNotEqual(classify_triangle(10, 10, 3), 'Scalene', '10, 10, 3 is an isosceles triangle')
コード例 #6
0
 def test_isosceles(self):
     # This function will tell us whether the triangle is isosceles triangle or not
     self.assertEqual(classify_triangle(2, 2, 3), 'Isosceles', '2, 2, 3 is an isosceles triangle')
     self.assertEqual(classify_triangle(12, 13, 12), 'Isosceles', '12, 13, 12 is an isosceles triangle')
     self.assertEqual(classify_triangle(10, 10, 8), 'Isosceles', '10, 10, 8 is an isosceles triangle')
     self.assertNotEqual(classify_triangle(10, 10, 10), 'Isosceles', '10, 10, 10 should be Equilateral')
コード例 #7
0
 def test_equilateral(self):
     # This function will tell us whether the triangle is equilateral triangle or not
     self.assertEqual(classify_triangle(1, 1, 1), 'Equilateral', '1,1,1 is an equilateral')
     self.assertNotEqual(classify_triangle(3, 3, 12), 'Equilateral', '3,3,12 is an isosceles')
     self.assertEqual(classify_triangle(15.5, 15.5, 15.5), 'Equilateral', '15.5, 15.5, 15.5 is an equilateral')