Exemplo n.º 1
0
def test_area():
    c = Circle(2)
    assert c.area == 12.566370614359172
    s = Sphere(2)
    assert s.area == 50.26548245743669
    s = Sphere(4)
    assert round(s.area, 5) == 201.06193

    with pytest.raises(AttributeError):
        c.area = 42
        s.area = 42
Exemplo n.º 2
0
def test_sphere_area():
    s = Sphere(3)

    assert s.area == 4 * pi * (3 ** 2)

    # Suface area should not be able to be set
    try:
        s.area = 10
    except AttributeError:
        pass
    else:
        assert False
Exemplo n.º 3
0
def test_area():
    s = Sphere(2)
    assert s.area == approx(50.2654824)

    with pytest.raises(AttributeError):
        s.area = 42
Exemplo n.º 4
0
def test_sphere_area():
    s = Sphere(4)

    with pytest.raises(NotImplementedError):
        s.area()
def test_sphere_volume_set():
    """ Verify sphere volume cannot be set by user """
    a_sphere = Sphere(5)
    with pytest.raises(AttributeError):
        a_sphere.area = 25