Ejemplo n.º 1
0
    def test_save(self):
        with TestAreaContext("polyline/fwrite") as work_area:
            p1 = Polyline(init_points=[(1, 0), (1, 1), (1, 2)])
            p2 = Polyline(init_points=[(1, 0), (1, 1), (1, 2)])
            self.assertTrue(p1 == p2)

            XYZIo.saveXYFile(p1, "poly.xy")

            p2 = XYZIo.readXYFile("poly.xy")
            self.assertTrue(p1 == p2)
Ejemplo n.º 2
0
    def test_construction(self):
        polyline = Polyline(name="test line")

        with self.assertRaises(IndexError):
            polyline.isClosed()

        self.assertEqual(polyline.getName(), "test line")

        self.assertEqual(len(polyline), 0)

        polyline.addPoint(0, 0, 0)
        self.assertEqual(len(polyline), 1)

        polyline.addPoint(1, 1, 0)
        self.assertEqual(len(polyline), 2)

        polyline.addPoint(1, 1.5)
        self.assertEqual(len(polyline), 3)

        self.assertEqual(polyline[0], (0, 0, 0))
        self.assertEqual(polyline[1], (1, 1, 0))
        self.assertEqual(polyline[2], (1, 1.5))

        polyline.addPoint(0, 1, 0)
        self.assertFalse(polyline.isClosed())

        polyline.addPoint(0, 0, 0)
        self.assertTrue(polyline.isClosed())