Exemple #1
0
def test_child_outside_parent():
    child = Rect.from_square(5)
    parent = Rect.from_square(6)

    def move_1px_right(child_rect, parent_rect):
        child_rect.left += 1

    # This should be fine the first time...
    glooey.drawing.align(move_1px_right, child, parent)

    # ...but out-of-bounds the second time.
    with pytest.raises(RuntimeError, match='move_1px_right'):
        glooey.drawing.align(move_1px_right, child, parent)
Exemple #2
0
def test_child_outside_parent():
    child = Rect.from_square(4.5)
    parent = Rect.from_square(6)

    def move_1px_right(child_rect, parent_rect):
        child_rect.left += 1

    # This should be fine the first time...
    glooey.drawing.align(move_1px_right, child, parent)

    # ...and also fine the second time, because the child is allowed to exceed
    # its parent by 1 px to account for rounding errors...
    glooey.drawing.align(move_1px_right, child, parent)

    # ...but out-of-bounds the third time.
    with pytest.raises(RuntimeError, match='move_1px_right'):
        glooey.drawing.align(move_1px_right, child, parent)