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