示例#1
0
def test_area(r):
    circle = Circle(1)
    circle.radius = r
    assert circle.area == np.pi * r ** 2
示例#2
0
def test_invalid_radius_setter():
    circle = Circle(1)
    with pytest.raises(ValueError):
        circle.radius = -1
示例#3
0
def test_perimeter(r):
    circle = Circle(1)
    circle.radius = r
    assert circle.perimeter == 2 * np.pi * r
    assert circle.circumference == 2 * np.pi * r
示例#4
0
def test_radius_getter_setter(r):
    """Test getting and setting the radius."""
    circle = Circle(r)
    assert circle.radius == r
    circle.radius = r + 1
    assert circle.radius == r + 1