Fix bug in rs274x Region close

Fixes gitlab issue #18
This commit is contained in:
jaseg 2026-03-08 13:23:29 +01:00
parent 8a2599f5f4
commit f3c95a42d4
2 changed files with 17 additions and 1 deletions

View file

@ -323,7 +323,7 @@ class Region(GraphicObject):
def close(self):
if self.outline and self.outline[-1] != self.outline[0]:
self.outline.append(self.outline[-1])
self.outline.append(self.outline[0])
if self.arc_centers:
self.arc_centers.append((None, (None, None)))

View file

@ -194,3 +194,19 @@ def test_region_arc_segments(start_angle_deg, sweep_angle_deg, tmpfile, img_supp
region.arc_centers.append(None)
gbr.objects.append(region)
def test_region_close():
""" Regression test for gitlab issue #18 """
go_region = Region([
(0, 0),
(100, 0),
(100, 100),
(0, 100),
# (0, 0), # expected
],
None,
polarity_dark=False,
unit=MM)
assert go_region.outline[-1] == go_region.outline[0]