Beispiel #1
0
def test_rectangle_centered_at():
    x, y = 1, 2
    radius = 2

    rect_centered_at_xy = Rectangle.centered_at(Point(x, y), radius)

    assert rect_centered_at_xy.area == (2 * radius)**2
    assert rect_centered_at_xy.width == 2 * radius
    assert rect_centered_at_xy.height == 2 * radius
    assert rect_centered_at_xy == Rectangle.from_list(
        (x - radius, y - radius, x + radius, y + radius))

    with pytest.raises(ValueError):
        Rectangle.centered_at(Point(1, 2), -1)
Beispiel #2
0
def test_rectangle_centered_at():
    x, y = 1, 2
    radius = 2

    rect_centered_at_xy = Rectangle.centered_at(Point(x, y), radius)

    assert rect_centered_at_xy.area == (2 * radius) ** 2
    assert rect_centered_at_xy.width == 2 * radius
    assert rect_centered_at_xy.height == 2 * radius
    assert rect_centered_at_xy == Rectangle.from_list((x - radius, y - radius, x + radius, y + radius))