Exemple #1
0
 def __constructWithCoords(self, x1, y1, x2, y2):
     try:
         self.__point1 = Point(x1, y1)
         self.__point2 = Point(x2, y2)
         Validator.validateLine(value=self, errorMessage="Line invalid")
         return True
     except ShapeException:
         return False
    def testValidateLine(self):
        l1 = Line(1, 1, -1, -5)
        Validator.validateLine(l1, "Line unexpectedly invalid")

        self.assertRaises(ShapeException, Validator.validateLine,
                          "(1, 1, -1, -5)",
                          "String \'(1, 1, -1, -5)\' is not a valid line")
        self.assertRaises(ShapeException, Validator.validateLine, Point(1, 1),
                          "Point is not a valid line")
Exemple #3
0
 def __constructWithPoints(self, point1, point2):
     try:
         Validator.validatePoint(point1, "Invalid point1")
         Validator.validatePoint(point2, "Invalid point2")
         self.__point1 = point1
         self.__point2 = point2
         Validator.validateLine(value=self, errorMessage="Line invalid")
         return True
     except ShapeException:
         return False