refactor tests for issue 414
@@ -447,15 +447,20 @@ S_SHAPE = [
]
-# original data for issue 414:
+class TestIssue414:
+ # Issue 414 shows an error in the bounding box calculation for a closed
+ # LWPOLYLINE representing a filled circle (const_width=0.45) and an
+ # inverted extrusion (0, 0, -1).
+ #
+ # original data of the LWPOLYLINE:
# [
# (-43710.28841108403, 19138.631023711587, 0.0, 0.0, -1.0),
# (-43710.28841108403, 19139.079023711445, 0.0, 0.0, -1.0),
# ]
-
-def lwpolyline_issue_414() -> LWPolyline:
- # simplified data for testing
+ @pytest.fixture
+ def lwpolyline(self) -> LWPolyline:
+ # simplified test data:
points = [(-10.0, 1.0, 0.0, 0.0, -1.0), (-10.0, 1.45, 0.0, 0.0, -1.0)]
pline = LWPolyline.new(
dxfattribs={"extrusion": (0, 0, -1), "const_width": 0.45}
@@ -464,17 +469,18 @@ def lwpolyline_issue_414() -> LWPolyline:
pline.close()
return pline
-
-def test_make_path_from_polyline2d_with_bulges_and_inverted_extrusion():
- pline = lwpolyline_issue_414()
- vertices = list(pline.vertices_in_wcs())
+ def test_WCS_calculation(self, lwpolyline):
+ vertices = list(lwpolyline.vertices_in_wcs())
assert vertices[0].isclose((10, 1, 0))
assert vertices[1].isclose((10, 1.45, 0))
- p = make_path(pline)
- box = tools.bbox([p])
+ def test_make_path(self, lwpolyline):
+ p = make_path(lwpolyline)
assert p.start.isclose((10, 1, 0))
assert p.is_closed is True
+
+ def test_bounding_box_calculation(self, lwpolyline):
+ box = tools.bbox([make_path(lwpolyline)])
assert box.extmin.isclose((9.775, 1.0))
assert box.extmax.isclose((10.225, 1.45))
