예제 #1
0
def test_polygon_area_function_pentagon():
    side_length = random.uniform(0, 10000)
    area = polygon_area(side_length, sides=5)
    assert math.isclose(
        area, 0.25 * side_length**2 *
        (5 *
         ((5 + 2 *
           (5)**0.5)))**0.5), "Check your Polygon area function for pentagon"
예제 #2
0
def test_polygon_area_function_negative_number_of_sides_input():
    side_length = random.uniform(0, 10000)
    area = polygon_area(side_length, sides=-1)
    assert area == None, " Check your Polygon area function for negative  input sides"
예제 #3
0
def test_polygon_area_function_area_hexagon():
    side_length = random.uniform(0, 10000)
    area = polygon_area(side_length, sides=6)
    assert math.isclose(
        area, 1.5 * (3**0.5) *
        side_length**2), " Check your Polygon area function for hexagoan"
예제 #4
0
def test_polygon_area_triangle():
    side_length = random.uniform(0, 10000)
    area = polygon_area(side_length, sides=3)
    assert math.isclose(
        area, (3**0.5) / 4 *
        side_length**2), " Check your Polygon area function area of Triangle"
예제 #5
0
def test_polygon_area_function_square():
    side_length = random.uniform(0, 10000)
    area = polygon_area(side_length, sides=4)
    assert math.isclose(
        area, side_length**2), " Check your Polygon area function for square"
예제 #6
0
def test_polygon_area_rectangle():
    assert math.isclose(program.polygon_area(2, sides=4), 4, abs_tol=0.1)
예제 #7
0
def test_polygon_area_hexagon():
    assert math.isclose(session4.polygon_area(15, sides=6),
                        584.567,
                        abs_tol=0.01)
예제 #8
0
def test_polygon_area_traingle():
    assert math.isclose(session4.polygon_area(15, sides=3),
                        97.4279,
                        abs_tol=0.01)
예제 #9
0
def test_polygon_area_square():
    assert math.isclose(session4.polygon_area(15, sides=4), 225, abs_tol=0.01)
예제 #10
0
def test_polygon_area_invalid_arguments():
    with pytest.raises(TypeError):
        session4.polygon_area('123', sides=4)
        session4.polygon_area(12, sides=12.5)
예제 #11
0
def test_polygon_area_invalid_values():
    with pytest.raises(ValueError):
        session4.polygon_area(-2, sides=4)
        session4.polygon_area(4, sides=8)
예제 #12
0
def test_polygon_area_for_valueerror():
    with pytest.raises(ValueError):
        program.polygon_area(2, sides=7)
예제 #13
0
def test_polygon_area_hexagon():
    assert math.isclose(program.polygon_area(2, sides=6), 10.39, abs_tol=0.1)
예제 #14
0
def test_polygon_area_pentagon():
    assert math.isclose(program.polygon_area(2, sides=5), 6.88191, abs_tol=0.1)
예제 #15
0
def test_polygon_area_function_negative_length_input():
    side_length = random.uniform(-10000, 0)
    side_length = random.uniform(-10000, 0)
    area = polygon_area(side_length, sides=3)
    assert area == None, " Check your Polygon area function for negative  input length"
예제 #16
0
def test_polygon_area_pentagon():
    assert math.isclose(session4.polygon_area(15, sides=5),
                        387.107,
                        abs_tol=0.01)
예제 #17
0
def test_polygon_area_function_side_non_standard_input():
    side_length = random.uniform(0, 10000)
    sides = random.randint(7, 10000)
    area = polygon_area(side_length, sides=sides)
    assert area == None, " Check your Polygon area function for negative  input length"
예제 #18
0
def test_polygon_area_triangle():
    assert math.isclose(program.polygon_area(2, sides=3), 1.73, abs_tol=0.1)