Exemple #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
Exemple #2
0
def test_rect_truediv_empty():
    r = Rect()
    s = Rect()
    with pytest.raises(ZeroDivisionError):
        _ = r / s
Exemple #3
0
def test_rect_itruediv_empty_rect():
    r = Rect(1, 2, 3, 4)
    s = Rect()
    with pytest.raises(ZeroDivisionError):
        r /= s
Exemple #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
Exemple #5
0
def test_rect_truediv_empty_point():
    p = Point()
    r = Rect(1, 2, 3, 4)
    with pytest.raises(ZeroDivisionError):
        _ = r / p
Exemple #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
Exemple #7
0
def test_point_not_in_rect():
    p = Point()
    bb = Rect(1, 1, 2, 2)
    assert p not in bb
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #15
0
def test_rect_in_rect():
    bb = Rect(1, 1, 1, 1)
    qq = Rect(0, 0, 3, 3)
    assert bb in qq
Exemple #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
Exemple #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
Exemple #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
Exemple #19
0
def test_point_in_rect():
    bb = Rect(1, 1, 2, 2)
    assert bb.center in bb
Exemple #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
Exemple #21
0
def test_rect_truediv_xy():
    r = Rect(1, 2)
    s = Rect(3, 4)
    with pytest.raises(ZeroDivisionError):
        _ = r / s
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #28
0
def test_rect_ifloordiv_empty_point():
    r = Rect(1, 2, 3, 4)
    p = Point()
    with pytest.raises(ZeroDivisionError):
        r //= p
Exemple #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
Exemple #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