コード例 #1
0
ファイル: test_circle.py プロジェクト: zmeves/SP_Online_PY210
def test_sphere_volume():
    s = Sphere(3)

    assert s.volume == 4 / 3 * pi * (3 ** 3)

    # Volume should not be able to be set
    try:
        s.volume = 10
    except AttributeError:
        pass
    else:
        assert False
コード例 #2
0
def test_sphere():
    """
    tests sphere area and volume to a relative tolerance
    to one one-hundredth. tests ability to change sphere
    volume and calculate correct resulting volume and radius.
    :return: None
    """
    s1 = Sphere(15)
    assert str(s1) == "Sphere with radius: 15.000000"
    assert repr(s1) == "Sphere(15)"
    assert isclose(s1.volume, 943, rel_tol=.01)
    assert isclose(s1.area, 2827.43, rel_tol=.01)
    s1.volume = 7
    assert isclose(s1.volume, 7, rel_tol=.01)
    assert isclose(s1.radius, 1.29, rel_tol=.01)
    s2 = Sphere.from_diameter(18)
    assert s2.radius == 9
コード例 #3
0
def test_sphere_vol():
    s = Sphere(4)

    print(s.volume())
    assert s.volume() == 268.082573106329
コード例 #4
0
def test_sphere_volume():
    s = Sphere(5)

    print(s.volume())

    assert s.volume() == 654.4984694978737
def test_volume():
    s1 = Sphere(4)

    assert s1.volume() == 268.082573106329
コード例 #6
0
ファイル: circle_test.py プロジェクト: Chieu1/SP_Online_PY210
def test_volume():
    s1 = Sphere(10)
    assert round(s1.volume(), 2) == 4186.67
コード例 #7
0
def test_sphere():
    example = Sphere(2)
    assert example.volume() == (4/3)*pi*8
コード例 #8
0
def test_sphere():
    s = Sphere(4)
    assert s.volume() == (4 / 3) * math.pi * 4**3
    assert s.surface_area() == 4 * math.pi * 4**2
コード例 #9
0
def sphere_test():
    s = Sphere(2)
    assert s.volume() == (4 / 3) * math.pi * 2**3
    assert s.surfuce_area() == 4 * math.pi * 2**2