def test_area(r): circle = Circle(1) circle.radius = r assert circle.area == np.pi * r ** 2
def test_invalid_radius_setter(): circle = Circle(1) with pytest.raises(ValueError): circle.radius = -1
def test_perimeter(r): circle = Circle(1) circle.radius = r assert circle.perimeter == 2 * np.pi * r assert circle.circumference == 2 * np.pi * r
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