Example #1
0
def test_compare():
    c1 = Circle(2)
    c2 = Circle(4)
    assert (c1 > c2) == False

    assert (c1 < c2) == True

    assert (c1 == c2) == False

    c3 = Circle(4)

    assert (c2 == c3) == True
Example #2
0
def test_multiply_reflection():
    c2 = Circle(4)
    c3 = 3 * c2
    assert c3.radius == 12
Example #3
0
def test_multiply():
    c2 = Circle(4)
    c3 = c2 * 3
    assert c3.radius == 12
Example #4
0
def test_add():
    c1 = Circle(2)
    c2 = Circle(4)
    c3 = c1 + c2
    assert c3.radius == 6
Example #5
0
def test_repr():
    c = Circle(4)
    repr(c) == 'Circle(4)'
Example #6
0
def test_str():
    c = Circle(4)
    assert str(c) == 'Circle with radius: 4.000000'
Example #7
0
def test_create_by_diameter():
    c = Circle.circle_d(14)
    assert c.diameter == 14
    assert c.radius == 7
    assert c.area == math.pi * 7**2
Example #8
0
def test_reflected():
    a_circle = Circle(3)
    assert a_circle * 3 == 3 * a_circle
Example #9
0
def test_change_diameter():
    c = Circle(5)
    c.diameter = 12
    assert c.diameter == 12
    assert c.radius == 6
Example #10
0
def test_change_radius():
    c = Circle(5)
    c.radius = 2
    assert c.diameter == 4
Example #11
0
def test_diameter():
    c = Circle(5)
    assert c.diameter == 10
Example #12
0
def test_augmented_assignment_mul():
    c1 = Circle(2)
    c1 *= 2

    assert c1.radius == 4
Example #13
0
def test_augmented_assignment_add():
    c1 = Circle(2)
    c2 = Circle(4)
    c1 += c2

    assert c1.radius == 6
Example #14
0
def test_divide_reflection():
    c2 = Circle(4)
    c3 = 12 / c2
    assert c3.radius == 3
Example #15
0
def test_divide():
    c2 = Circle(6)
    c3 = c2 / 3
    assert c3.radius == 2
Example #16
0
def test_area():
    c = Circle(4)
    assert c.area == math.pi * 4**2
Example #17
0
def test_sorting():
    circles = [
        Circle(6),
        Circle(7),
        Circle(8),
        Circle(4),
        Circle(0),
        Circle(2),
        Circle(3),
        Circle(5),
        Circle(9),
        Circle(1)
    ]
    circles.sort()
    assert circles == [
        Circle(0),
        Circle(1),
        Circle(2),
        Circle(3),
        Circle(4),
        Circle(5),
        Circle(6),
        Circle(7),
        Circle(8),
        Circle(9)
    ]
Example #18
0
def test_radius():
    c = Circle(4)
    assert c.radius == 4