def test_create_rect_from_corners(self): '''Test for Rectangle.from_corners()''' rect = Rectangle.from_corners(0, 1, 2, 4) self.assertEqual(rect.x, 0) self.assertEqual(rect.y, 1) self.assertEqual(rect.width, 2) self.assertEqual(rect.height, 3)
def test_rectangle_max_point(self): '''Test Rectangle.max_point()''' rect = Rectangle(-2, -3, 8, 5) bottom_right = rect.max_point() self.assertEqual(bottom_right.x, 6) self.assertEqual(bottom_right.y, 2)
def test_rectangle_min_point(self): '''Test Rectangle.min_point()''' rect = Rectangle(-2, -3, 8, 5) top_left = rect.min_point() self.assertEqual(top_left.x, -2) self.assertEqual(top_left.y, -3)
def parse_box(self, args): """ Returns a parsed box. """ x1, y1, x2, y2 = [int(a) for a in args.split()] return ('shape', Rectangle.from_corners(x1, y1, x2, y2))