def test_clip_x_infinite(): """ Test correctly clipping (-inf, 0, inf, 10) with (-inf, -inf, inf, inf) """ box1 = Box(Rectangle(-inf, -inf, inf, inf)) box2 = Box(Rectangle(-inf, 0, inf, 10)) clipped = box1.clip(box2) assert_is_not(clipped, Box.empty_box) assert_equals(clipped.rect, (-inf, 0, inf, 10))
def test_clip_identity(): """ Test clipping a box with itself results in the same box """ box1 = Box(Rectangle(-inf, -inf, inf, inf)) box2 = Box(Rectangle(-inf, -inf, inf, inf)) clipped = box1.clip(box2) assert_is_not(clipped, Box.empty_box) assert_equals(clipped.rect, box1.rect)