def testValidateTriangle(self): t1 = Triangle(1, 1, -1, -5, -3, -2) Validator.validateTriangle(t1, "Triangle unexpectedly invalid") self.assertRaises( ShapeException, Validator.validateLine, "(1, 1, -1, -5, -3, -2)", "String \'(1, 1, -1, -5, -3, -2)\' is not a valid triangle") self.assertRaises(ShapeException, Validator.validateLine, Point(1, 1), "Point is not a valid triangle")
def __constructWithLines(self, line1, line2, line3): try: self.__line1 = line1 self.__line2 = line2 self.__line3 = line3 Validator.validateTriangle(value=self, errorMessage="Triangle invalid") return True except ShapeException: return False
def __constructWithPoints(self, point1, point2, point3): try: self.__line1 = Line(point1, point2) self.__line2 = Line(point2, point3) self.__line3 = Line(point3, point1) Validator.validateTriangle(value=self, errorMessage="Triangle invalid") return True except ShapeException: return False
def __constructWithCoords(self, x1, y1, x2, y2, x3, y3): try: self.__line1 = Line(x1, y1, x2, y2) self.__line2 = Line(x2, y2, x3, y3) self.__line3 = Line(x3, y3, x1, y1) Validator.validateTriangle(value=self, errorMessage="Triangle invalid") return True except ShapeException: return False