def test_set_volume(volume): """Test setting the volume.""" sphere = Sphere(1) sphere.volume = volume assert sphere.volume == approx(volume) assert sphere.radius == approx((3 * volume / (4 * np.pi))**(1 / 3))
def test_invalid_volume_setter(volume): """Test setting an invalid Volume.""" sphere = Sphere(1) with pytest.raises(ValueError): sphere.volume = volume