コード例 #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)