Skip to content

Commit aeb799b

Browse files
committed
MGG-1656 [#ccc] svgpathtools: Adding test cases to validate fixes
* Added polyline.svg and polygons_no_poits.svg to validate recent changes to svgpathtools Signed-off-by: Nilam Gaikwad <[email protected]>
1 parent b174f99 commit aeb799b

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

test/polygons_no_points.svg

Lines changed: 5 additions & 0 deletions
Loading

test/polyline.svg

Lines changed: 7 additions & 0 deletions
Loading

test/test_svg2paths.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,44 @@ def test_from_string(self):
168168

169169
self.assertEqual(len(paths), 2)
170170

171+
def test_svg2paths_polygon_no_points(self):
172+
173+
paths, _ = svg2paths(join(dirname(__file__), 'polygons_no_points.svg'))
174+
175+
path = paths[0]
176+
path_correct = Path()
177+
self.assertTrue(len(path)==0)
178+
self.assertTrue(path==path_correct)
179+
180+
path = paths[1]
181+
self.assertTrue(len(path)==0)
182+
self.assertTrue(path==path_correct)
183+
184+
def test_svg2paths_polyline_tests(self):
185+
186+
paths, _ = svg2paths(join(dirname(__file__), 'polyline.svg'))
187+
188+
path = paths[0]
189+
path_correct = Path(Line(59+185j, 98+203j),
190+
Line(98+203j, 108+245j),
191+
Line(108+245j, 82+279j),
192+
Line(82+279j, 39+280j),
193+
Line(39+280j, 11+247j),
194+
Line(11+247j, 19+205j))
195+
self.assertFalse(path.isclosed())
196+
self.assertTrue(len(path)==6)
197+
self.assertTrue(path==path_correct)
198+
199+
path = paths[1]
200+
path_correct = Path(Line(220+50j, 267+84j),
201+
Line(267+84j, 249+140j),
202+
Line(249+140j, 190+140j),
203+
Line(190+140j, 172+84j),
204+
Line(172+84j, 220+50j))
205+
self.assertTrue(path.isclosed())
206+
self.assertTrue(len(path)==5)
207+
self.assertTrue(path==path_correct)
208+
171209

172210
if __name__ == '__main__':
173211
unittest.main()

0 commit comments

Comments
 (0)