예제 #1
0
def test_sort():
    c1 = cr.Circle(1)
    c2 = cr.Circle(2)
    c3 = cr.Circle(3)
    c4 = cr.Circle(4)
    c5 = cr.Circle(4)
    c6 = cr.Circle(6)
    circle_list = [c2, c5, c4, c1, c6, c3]
    circle_list.sort(key=cr.Circle.sort_key)
    assert circle_list == [c1, c2, c3, c4, c5, c6]
예제 #2
0
def test_str():
    c1 = cr.Circle(9)
    assert str(c1) == "Circle with radius: 9.000000"
예제 #3
0
def test_repr():
    c1 = cr.Circle(5)
    assert repr(c1) == 'Circle(5)'
예제 #4
0
def test_from_diameter():
    c1 = cr.Circle(7)
    c1.from_diameter(8)
예제 #5
0
def test_lt():
    c1 = cr.Circle(14)
    c2 = cr.Circle(12)
    assert c2 < c1
예제 #6
0
def test_gt():
    c1 = cr.Circle(14)
    c2 = cr.Circle(13)
    assert (c1 > c2)
예제 #7
0
def test_mul_augmented():
    c1 = cr.Circle(12)
    c1 *= 3
    assert c1.radius == 36
예제 #8
0
def test_add_augmented():
    c1 = cr.Circle(11)
    c2 = cr.Circle(7)
    c1 += c2
    assert c1.radius == 18
예제 #9
0
def test_radius():
    c1 = cr.Circle(4)
    assert c1.radius == 4
예제 #10
0
def test_radius_0():
    # with pytest.raises(ValueError):
    c1 = cr.Circle(0)
예제 #11
0
def test_truediv():
    c1 = cr.Circle(14)
    c2 = cr.Circle(23)
    c1 /= 2
    with pytest.raises(ValueError):
        c2 /= 0
예제 #12
0
def test_ne():
    c1 = cr.Circle(15)
    c2 = cr.Circle(15)
    assert c1 != c2
예제 #13
0
def test_eq():
    c1 = cr.Circle(14)
    c2 = cr.Circle(14)
    assert c1 == c2
예제 #14
0
def test_le():
    c1 = cr.Circle(14)
    c2 = cr.Circle(14)
    c3 = cr.Circle(22)
    assert c1 <= c2
    assert c2 <= c3
예제 #15
0
def test_init():
    c1 = cr.Circle(3)
예제 #16
0
def test_diameter():
    c1 = cr.Circle(4)
    assert c1.diameter == 8
예제 #17
0
def test_add():
    c1 = cr.Circle(11)
    c2 = cr.Circle(7)
    assert (c1 + c2).radius == 18
예제 #18
0
def test_set_diameter():
    c1 = cr.Circle(7)
    assert c1.diameter == 14
    c1.diameter = 10
    assert c1.radius == 5
예제 #19
0
def test_mul():
    c1 = cr.Circle(14)
    assert (c1 * 3).radius == 42
예제 #20
0
def test_area():
    c1 = cr.Circle(2)
    assert c1.area == 12.566370614359172
예제 #21
0
def test_rmul():
    c1 = cr.Circle(14)
    assert (3 * c1).radius == 42
예제 #22
0
def test_fail_to_set_area():
    c1 = cr.Circle(2)
    with pytest.raises(AttributeError):
        c1.area = 56
예제 #23
0
def test_ge():
    c1 = cr.Circle(14)
    c2 = cr.Circle(14)
    c3 = cr.Circle(23)
    assert c1 >= c2
    assert c3 >= c1
예제 #24
0
def test_constructor_requires_parameter():
    with pytest.raises(TypeError):
        c2 = cr.Circle()