def test_interpolation_for_coincident_vertices_after(self):
     cp = ConstructionPolyline([(0, 0), (1, 0), (1, 0), (1, 0)])
     assert cp.vertex_at(0.0).isclose((0.0, 0.0))
     assert cp.vertex_at(0.1).isclose((0.1, 0.0))
     assert cp.vertex_at(0.5).isclose((0.5, 0.0))
     assert cp.vertex_at(0.9).isclose((0.9, 0.0))
     assert cp.vertex_at(1.0).isclose((1.0, 0.0))
 def test_long_polyline(self):
     poly = ConstructionPolyline([(0, 0), (1, 0), (2, 0), (3, 0)])
     assert poly.index_at(0.0) == 0
     assert poly.index_at(0.999) == 1
     assert poly.index_at(1.0) == 1
     assert poly.index_at(1.001) == 2
     assert poly.index_at(1.999) == 2
     assert poly.index_at(2.0) == 2
     assert poly.index_at(2.001) == 3
     assert poly.index_at(2.999) == 3
     assert poly.index_at(3.0) == 3
     assert poly.index_at(3.001) == 3
    def test_unit_circle_by_path(self):
        from ezdxf import path

        p = path.unit_circle()
        cp = ConstructionPolyline(p.flattening(0.01))
        assert cp.is_closed is True
        assert len(cp) > 60
        assert abs(cp.length - math.tau) < 0.002
    def test_unit_circle(self):
        from ezdxf.entities import Circle

        # create unit circle
        circle: Circle = Circle.new(dxfattribs={
            "center": (0, 0),
            "radius": 1.0
        })
        cp = ConstructionPolyline(circle.flattening(0.01))
        assert cp.is_closed is True
        assert len(cp) > 20
        assert abs(cp.length - math.tau) < 0.02
 def test_empty_polyline(self):
     assert ConstructionPolyline([]).length == 0.0
 def test_vertices_at_the_same_location(self):
     cp = ConstructionPolyline([(0, 0), (0, 0), (0, 0)])
     assert cp.data(0) == (0, 0, (0, 0))
     assert cp.data(1) == (0, 0, (0, 0))
     assert cp.data(2) == (0, 0, (0, 0))
 def test_empty_polyline_raises_Value_error(self):
     with pytest.raises(ValueError):
         ConstructionPolyline([]).data(0)
 def test_empty_polyline(self):
     cp = ConstructionPolyline([])
     assert len(cp) == 0
 def test_polyline_with_too_few_vertices_is_not_closed(self):
     assert ConstructionPolyline([(0, 0)]).is_closed is False
     assert ConstructionPolyline([(0, 0), (0, 0)]).is_closed is False
 def test_too_few_vertices_raises_error(self):
     with pytest.raises(ValueError):
         ConstructionPolyline([(0, 0)]).vertex_at(0.0)
 def test_empty_polyline_raises_error(self):
     with pytest.raises(ValueError):
         ConstructionPolyline([]).vertex_at(0.0)
def poly2() -> ConstructionPolyline:
    return ConstructionPolyline([(0, 0), (1, 0), (1, 1), (0, 1)], close=True)
 def test_short_polyline(self):
     poly = ConstructionPolyline([(0, 0), (1, 0)])
     assert poly.index_at(0.0) == 0
     assert poly.index_at(0.5) == 1
     assert poly.index_at(1) == 1
 def test_polyline_with_one_vertex(self, d):
     assert ConstructionPolyline([(1, 1)]).index_at(d) == 0
 def test_empty_polyline(self, d):
     assert ConstructionPolyline([]).index_at(d) == 0
def poly1() -> ConstructionPolyline:
    return ConstructionPolyline([(0, 0), (1, 0), (1, 1), (0, 1)])
 def test_vertices_at_the_same_location(self):
     cp = ConstructionPolyline([(0, 0), (0, 0), (0, 0)])
     assert cp.length == 0.0
 def test_empty_polyline_is_not_closed(self):
     assert ConstructionPolyline([]).is_closed is False