Пример #1
0
def test_region_intersection():
    assert Region(0, 0, 100,
                  50).intersection(Region(10, 10, 10,
                                          10)) == Region(10, 10, 10, 10)
    assert Region(10, 10, 30,
                  20).intersection(Region(20, 15, 60,
                                          40)) == Region(20, 15, 20, 15)

    assert not Region(10, 10, 20, 30).intersection(Region(50, 50, 100, 200))
Пример #2
0
def test_region_y_extents():
    assert Region(5, 10, 20, 30).y_extents == (10, 40)
Пример #3
0
def test_region_x_extents():
    assert Region(5, 10, 20, 30).x_extents == (5, 25)
Пример #4
0
def test_region_union():
    assert Region(5, 5, 10, 10).union(Region(20, 30, 10,
                                             5)) == Region(5, 5, 25, 30)
Пример #5
0
def test_region_origin():
    assert Region(1, 2, 3, 4).origin == Offset(1, 2)
Пример #6
0
def test_region_from_origin():
    assert Region.from_origin(Offset(3, 4), (5, 6)) == Region(3, 4, 5, 6)
Пример #7
0
def test_dimensions_region():
    assert Size(30, 40).region == Region(0, 0, 30, 40)
Пример #8
0
def test_region_x_range():
    assert Region(5, 10, 20, 30).x_range == range(5, 25)
Пример #9
0
def test_region_contains_region():
    assert Region(10, 10, 20, 30).contains_region(Region(10, 10, 5, 5))
    assert not Region(10, 10, 20, 30).contains_region(Region(10, 9, 5, 5))
    assert not Region(10, 10, 20, 30).contains_region(Region(9, 10, 5, 5))
    assert Region(10, 10, 20, 30).contains_region(Region(10, 10, 20, 30))
    assert not Region(10, 10, 20, 30).contains_region(Region(10, 10, 21, 30))
    assert not Region(10, 10, 20, 30).contains_region(Region(10, 10, 20, 31))
Пример #10
0
def test_region_contains_point():
    assert Region(10, 10, 20, 30).contains_point((10, 10))
    assert Region(10, 10, 20, 30).contains_point((29, 39))
    assert not Region(10, 10, 20, 30).contains_point((30, 40))
    with pytest.raises(TypeError):
        Region(10, 10, 20, 30).contains_point((1, 2, 3))
Пример #11
0
def test_region_contains():
    assert Region(10, 10, 20, 30).contains(10, 10)
    assert Region(10, 10, 20, 30).contains(29, 39)
    assert not Region(10, 10, 20, 30).contains(30, 40)
Пример #12
0
def test_region_overlaps():
    assert Region(10, 10, 30, 20).overlaps(Region(0, 0, 20, 20))
    assert not Region(10, 10, 5, 5).overlaps(Region(15, 15, 20, 20))

    assert not Region(10, 10, 5, 5).overlaps(Region(0, 0, 50, 10))
    assert Region(10, 10, 5, 5).overlaps(Region(0, 0, 50, 11))
    assert not Region(10, 10, 5, 5).overlaps(Region(0, 15, 50, 10))
    assert Region(10, 10, 5, 5).overlaps(Region(0, 14, 50, 10))
Пример #13
0
def test_region_sub():
    assert Region(11, 22, 3, 4) - (10, 20) == Region(1, 2, 3, 4)
    with pytest.raises(TypeError):
        Region(1, 2, 3, 4) - "foo"
Пример #14
0
def test_region_add():
    assert Region(1, 2, 3, 4) + (10, 20) == Region(11, 22, 3, 4)
    with pytest.raises(TypeError):
        Region(1, 2, 3, 4) + "foo"
Пример #15
0
def test_region_x_max():
    assert Region(5, 10, 20, 30).x_max == 25
Пример #16
0
def test_region_y_max():
    assert Region(5, 10, 20, 30).y_max == 40
Пример #17
0
def test_region_translate():
    assert Region(1, 2, 3, 4).translate(10, 20) == Region(11, 22, 3, 4)
    assert Region(1, 2, 3, 4).translate(y=20) == Region(1, 22, 3, 4)
Пример #18
0
def test_region_y_range():
    assert Region(5, 10, 20, 30).y_range == range(10, 40)
Пример #19
0
def test_region_contains_special():
    assert (10, 10) in Region(10, 10, 20, 30)
    assert (9, 10) not in Region(10, 10, 20, 30)
    assert Region(10, 10, 5, 5) in Region(10, 10, 20, 30)
    assert Region(5, 5, 5, 5) not in Region(10, 10, 20, 30)
    assert "foo" not in Region(0, 0, 10, 10)
Пример #20
0
def test_region_null():
    assert Region() == Region(0, 0, 0, 0)
    assert not Region()
Пример #21
0
def test_clip():
    assert Region(10, 10, 20, 30).clip(20, 25) == Region(10, 10, 10, 15)
Пример #22
0
def test_region_area():
    assert Region(3, 4, 0, 0).area == 0
    assert Region(3, 4, 5, 6).area == 30
Пример #23
0
def test_region_size():
    assert isinstance(Region(3, 4, 5, 6).size, Size)
    assert Region(3, 4, 5, 6).size == Size(5, 6)