Exemplo n.º 1
0
class AllShapesTestCase(ShapeTestCase):

    _base_circle = Circle(80)
    _rectangle = Rectangle(100, 60)
    _spacer = Spacer(40, 40)
    _square = Square(80)
    _vertical_shapes = VerticalShapes(
        _base_circle,
        LayeredShapes(ScaledShape(_base_circle, 0.75, 0.75), Polygon(5, 20)),
        LayeredShapes(ScaledShape(_base_circle, 0.5, 0.5),
                      RotatedShape(Triangle(20), 180)))
    _shape = HorizontalShapes(_rectangle, _spacer, _square, _vertical_shapes,
                              _square, _spacer, _rectangle)

    def test_get_width(self):
        self.assertEqual(self._shape._get_width(), 600)

    def test_get_height(self):
        self.assertEqual(self._shape._get_height(), 360)

    def test_export_postscript_all_shapes(self):
        self._test_export_postscript(self._shape, Point(305, 300))
Exemplo n.º 2
0
    Point, Rectangle, Spacer, Square, Circle, HorizontalShapes, VerticalShapes,
    LayeredShapes, ScaledShape, RotatedShape, Triangle, Polygon
)

if __name__ == "__main__":
    base_circle = Circle(80)
    rectangle = Rectangle(100, 60)
    spacer = Spacer(40, 40)
    square = Square(80)
    vertical_shapes = VerticalShapes(
        base_circle,
        LayeredShapes(
            ScaledShape(base_circle, 0.75, 0.75), Polygon(5, 20)
        ),
        LayeredShapes(
            ScaledShape(base_circle, 0.5, 0.5), RotatedShape(Triangle(20), 180)
        )
    )
    shape = HorizontalShapes(
        rectangle,
        spacer,
        square,
        vertical_shapes,
        square,
        spacer,
        rectangle
    )
    shape.export_postscript(
        center=Point(305, 300), filename="weird-snowperson.ps"
    )
Exemplo n.º 3
0
 def test_create_90(self):
     RotatedShape(Rectangle(10, 20), 90)
Exemplo n.º 4
0
 def test_get_height_270(self):
     shape = RotatedShape(Rectangle(20, 30), 270)
     self.assertEqual(shape._get_height(), 20)
Exemplo n.º 5
0
 def test_get_width_270(self):
     shape = RotatedShape(Rectangle(20, 30), 270)
     self.assertEqual(shape._get_width(), 30)
Exemplo n.º 6
0
 def test_value_error_720(self):
     with self.assertRaises(ValueError):
         RotatedShape(Rectangle(10, 20), 720)
Exemplo n.º 7
0
 def test_value_error_negative(self):
     with self.assertRaises(ValueError):
         RotatedShape(Rectangle(10, 20), -90)
Exemplo n.º 8
0
 def test_create_270(self):
     RotatedShape(Rectangle(10, 20), 270)
Exemplo n.º 9
0
 def test_create_180(self):
     RotatedShape(Rectangle(10, 20), 180)