diff --git a/test/test_svg2paths.py b/test/test_svg2paths.py index fe2507a..4aec225 100644 --- a/test/test_svg2paths.py +++ b/test/test_svg2paths.py @@ -3,8 +3,11 @@ import unittest from svgpathtools import Path, Line, Arc, svg2paths, svgstr2paths from io import StringIO from io import open # overrides build-in open for compatibility with python2 +import os from os.path import join, dirname from sys import version_info +import tempfile +import shutil from svgpathtools.svg_to_paths import rect2pathd @@ -57,6 +60,26 @@ class TestSVG2Paths(unittest.TestCase): self.assertTrue(path_circle==path_circle_correct) self.assertTrue(path_circle.isclosed()) + # test for issue #198 (circles not being closed) + svg = u""" + + + + + + + """ + tmpdir = tempfile.mkdtemp() + svgfile = os.path.join(tmpdir, 'test.svg') + with open(svgfile, 'w') as f: + f.write(svg) + paths, _ = svg2paths(svgfile) + self.assertEqual(len(paths), 2) + self.assertTrue(paths[0].isclosed()) + self.assertTrue(paths[1].isclosed()) + shutil.rmtree(tmpdir) + def test_rect2pathd(self): non_rounded = {"x":"10", "y":"10", "width":"100","height":"100"} self.assertEqual(rect2pathd(non_rounded), 'M10.0 10.0 L 110.0 10.0 L 110.0 110.0 L 10.0 110.0 z') @@ -107,3 +130,7 @@ class TestSVG2Paths(unittest.TestCase): paths, _ = svgstr2paths(file_content) self.assertEqual(len(paths), 2) + + +if __name__ == '__main__': + unittest.main()