def test_sphere_alt_constructor():
    my_sphere = Sphere.from_diameter(8)
    assert repr(my_sphere) == 'Sphere(4)'
    assert my_sphere.diameter == 8
def my_sphere():
    return Sphere(4)
示例#3
0
def test_sphere_from_diameter():
    s = Sphere.from_diameter(8)
    assert s.radius == 4
示例#4
0
def test_sphere_adding():
    s1 = Sphere(2)
    s2 = Sphere(3)
    assert s1 + s2 == Sphere(5)
示例#5
0
def test_sphere_area():
    s = Sphere(4)
    print(s.area)
    assert "{:.2f}".format(s.area) == '201.06'
示例#6
0
def test_sphere_volume():
    s = Sphere(4)
    print(s)
    print(s.volume)
    assert "{:.2f}".format(s.volume) == '268.08'
示例#7
0
def test_sphere_repr():
    s = Sphere(4)
    assert (repr(s)) == "Sphere(4)"
示例#8
0
def test_sphere_string():
    s = Sphere(4)
    assert s.__str__() == "Sphere with radius: 4.000000"
示例#9
0
def test_sphere_init():
    Sphere()
    Sphere(4)