Exemplo n.º 1
0
def test_rect_sub_wh():
    r = Rect(w=1, h=2)
    s = Rect(w=3, h=4)
    q = r - s
    assert q.x == 0 and q.y == 0 and q.w == -2 and q.h == -2
Exemplo n.º 2
0
def test_rect_truediv_empty():
    r = Rect()
    s = Rect()
    with pytest.raises(ZeroDivisionError):
        _ = r / s
Exemplo n.º 3
0
def test_rect_itruediv_empty_rect():
    r = Rect(1, 2, 3, 4)
    s = Rect()
    with pytest.raises(ZeroDivisionError):
        r /= s
Exemplo n.º 4
0
def test_rect_truediv_wh():
    r = Rect(w=1, h=2)
    s = Rect(w=3, h=4)
    with pytest.raises(ZeroDivisionError):
        _ = r / s
Exemplo n.º 5
0
def test_rect_truediv_empty_point():
    p = Point()
    r = Rect(1, 2, 3, 4)
    with pytest.raises(ZeroDivisionError):
        _ = r / p
Exemplo n.º 6
0
def test_rect_not_in_rect():
    bb = Rect(0, 0, 1, 1)
    qq = Rect(10, 10, 1, 1)
    assert bb not in qq
    assert qq not in bb
Exemplo n.º 7
0
def test_point_not_in_rect():
    p = Point()
    bb = Rect(1, 1, 2, 2)
    assert p not in bb
Exemplo n.º 8
0
def test_rect_mul_xy():
    r = Rect(1, 2)
    s = Rect(3, 4)
    q = r * s
    assert q.x == 3 and q.y == 8 and q.w == 0 and q.h == 0
Exemplo n.º 9
0
def test_rect_mul_wh():
    r = Rect(w=1, h=2)
    s = Rect(w=3, h=4)
    q = r * s
    assert q.x == 0 and q.y == 0 and q.w == 3 and q.h == 8
Exemplo n.º 10
0
def test_rect_isub_nonempty_point():

    r = Rect(1, 2, 3, 4)
    p = Point(1, 2)
    r -= p
    assert r.x == 0 and r.y == 0 and r.w == 3 and r.h == 4
Exemplo n.º 11
0
def test_rect_isub_empty_rect():
    r = Rect(1, 2, 3, 4)
    s = Rect()
    r -= s
    assert r.x == 1 and r.y == 2 and r.w == 3 and r.h == 4
Exemplo n.º 12
0
def test_rect_sub_nonempty_point():
    r = Rect(1, 2, 3, 4)
    p = Point(2, 3)
    q = r - p
    assert q.x == -1 and q.y == -1 and q.w == 3 and q.h == 4
Exemplo n.º 13
0
def test_rect_sub_empty_point():
    p = Point()
    r = Rect(1, 2, 3, 4)
    q = r - p
    assert q.x == 1 and q.y == 2 and q.w == 3 and q.h == 4
Exemplo n.º 14
0
def test_rect_sub_xywh():
    r = Rect(1, 2, 3, 4)
    s = Rect(5, 6, 7, 8)
    q = r - s
    assert q.x == -4 and q.y == -4 and q.w == -4 and q.h == -4
Exemplo n.º 15
0
def test_rect_in_rect():
    bb = Rect(1, 1, 1, 1)
    qq = Rect(0, 0, 3, 3)
    assert bb in qq
Exemplo n.º 16
0
def test_rect_mul_xywh():
    r = Rect(1, 2, 3, 4)
    s = Rect(5, 6, 7, 8)
    q = r * s
    assert q.x == 5 and q.y == 12 and q.w == 21 and q.h == 32
Exemplo n.º 17
0
def test_outer_rect_in_inner_rect():
    bb = Rect(1, 1, 1, 1)
    qq = Rect(0, 0, 3, 3)
    assert qq in bb
Exemplo n.º 18
0
def test_rect_mul_empty():
    r = Rect()
    s = Rect()
    q = r * s
    assert q.x == 0 and q.y == 0 and q.w == 0 and q.h == 0
    assert q == r and q == s and q is not r and q is not s
Exemplo n.º 19
0
def test_point_in_rect():
    bb = Rect(1, 1, 2, 2)
    assert bb.center in bb
Exemplo n.º 20
0
def test_rect_mul_empty_point():
    p = Point()
    r = Rect(1, 2, 3, 4)
    q = r * p
    assert q.x == 0 and q.y == 0 and q.w == 3 and q.h == 4
Exemplo n.º 21
0
def test_rect_truediv_xy():
    r = Rect(1, 2)
    s = Rect(3, 4)
    with pytest.raises(ZeroDivisionError):
        _ = r / s
Exemplo n.º 22
0
def test_rect_mul_nonempty_point():
    r = Rect(1, 2, 3, 4)
    p = Point(2, 3)
    q = r * p
    assert q.x == 2 and q.y == 6 and q.w == 3 and q.h == 4
Exemplo n.º 23
0
def test_rect_truediv_xywh():
    r = Rect(2, 4, 6, 8)
    s = Rect(2, 2, 2, 2)
    q = r / s
    assert q.x == 1 and q.y == 2 and q.w == 3 and q.h == 4
Exemplo n.º 24
0
def test_rect_imul_nonempty_point():
    r = Rect(1, 2, 3, 4)
    p = Point(1, 2)
    r *= p
    assert r.x == 1 and r.y == 4 and r.w == 3 and r.h == 4
Exemplo n.º 25
0
def test_rect_truediv_nonempty_point():
    r = Rect(2, 4, 6, 8)
    p = Point(2, 2)
    q = r / p
    assert q.x == 1 and q.y == 2 and q.w == 6 and q.h == 8
Exemplo n.º 26
0
def test_rect_imul_empty_rect():
    r = Rect(1, 2, 3, 4)
    s = Rect()
    r *= s
    assert r.x == 0 and r.y == 0 and r.w == 0 and r.h == 0
Exemplo n.º 27
0
def test_rect_itruediv_nonempty_point():
    r = Rect(2, 4, 6, 8)
    p = Point(2, 2)
    r /= p
    assert r.x == 1 and r.y == 2 and r.w == 6 and r.h == 8
Exemplo n.º 28
0
def test_rect_ifloordiv_empty_point():
    r = Rect(1, 2, 3, 4)
    p = Point()
    with pytest.raises(ZeroDivisionError):
        r //= p
Exemplo n.º 29
0
def test_rect_itruediv_nonempty_rect():
    r = Rect(2, 4, 6, 8)
    s = Rect(2, 2, 2, 2)
    r /= s
    assert r.x == 1 and r.y == 2 and r.w == 3 and r.h == 4
Exemplo n.º 30
0
def test_rect_sub_xy():
    r = Rect(1, 2)
    s = Rect(3, 4)
    q = r - s
    assert q.x == -2 and q.y == -2 and q.w == 0 and q.h == 0