Esempio n. 1
0
 def equilateral_triangle(self):
     formatted_name = classify_triangle(3, 3, 3)
     self.assertEqual(formatted_name, 'equilateral triangle')
Esempio n. 2
0
 def isosceles_triangle(self):
     formatted_name = classify_triangle(3, 3, 5)
     self.assertEqual(formatted_name, 'isosceles triangle')
Esempio n. 3
0
 def right_triangle(self):
     formatted_name = classify_triangle(3, 4, 5)
     self.assertEqual(formatted_name, 'right triangle')
Esempio n. 4
0
def test_right_order():
    """
    Test that a tirangle with a**2 + b**2 = c**2 triangle return 'right' even when c is not the third parameter
    Note: right triangles are also scalene.
    """
    assert 'right' == classify_triangle(5, 3, 4)
Esempio n. 5
0
 def scalene_triangle(self):
     formatted_name = classify_triangle(3, 4, 6)
     self.assertEqual(formatted_name, 'scalene triangle')
Esempio n. 6
0
def test_right():
    """
    Test that a tirangle with a**2 + b**2 = c**2 triangle returns 'right'
    Note: right triangles are also scalene.
    """
    assert 'right' == classify_triangle(3, 4, 5)
Esempio n. 7
0
def test_invalid_zero():
    """
    Test that an null size triangle returns 'invalid'
    """
    assert 'invalid' == classify_triangle(0, 0, 0)
Esempio n. 8
0
def test_isosceles():
    """
    Test that a triangle with two equal sides returns 'isosceles'
    """
    assert 'isosceles' == classify_triangle(2, 2, 3)
Esempio n. 9
0
def test_scalene():
    """
    Test that a triangle with three differnt sides returns 'scalene'
    """
    assert 'scalene' == classify_triangle(2, 3, 4)
Esempio n. 10
0
def test_equilateral():
    """
    Test that a triangle with three equal sides returns 'equilateral'
    Note: equilateral triangles are also isosceles
    """
    assert 'equilateral' == classify_triangle(1.2, 1.2, 1.2)
Esempio n. 11
0
def test_invalid_isosceles():
    """
    Test that an invalid triangle with two equal sides returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 1, 3)
Esempio n. 12
0
def test_invalid_scalene():
    """
    Test that an invalid triangle with three different lengths returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, 3)
Esempio n. 13
0
def test_nan():
    """
    Test that an invalid triangle with a not a number length returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, float('nan'))
Esempio n. 14
0
def test_inf():
    """
    Test that an invalid triangle with an infinite length returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, float('inf'))