From 0c9dd318aa271da12ae2d5f4123c0354b419b4ca Mon Sep 17 00:00:00 2001 From: tatarize Date: Thu, 16 Jul 2020 15:51:07 -0900 Subject: [PATCH] Fix Issue #99 + Test Coverage. (#115) --- svgpathtools/path.py | 1 + test/test_parsing.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/svgpathtools/path.py b/svgpathtools/path.py index e5102bb..97a0036 100644 --- a/svgpathtools/path.py +++ b/svgpathtools/path.py @@ -2941,6 +2941,7 @@ class Path(MutableSequence): if command is None: raise ValueError("Unallowed implicit command in %s, position %s" % ( pathdef, len(pathdef.split()) - len(elements))) + last_command = command # Used by S and T if command == 'M': # Moveto command. diff --git a/test/test_parsing.py b/test/test_parsing.py index 7897faa..1c93064 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -277,3 +277,11 @@ class TestParser(unittest.TestCase): path1 = parse_path("m 100 100 L 300 100 L 200 300 z", 50 + 50j) path2 = Path("m 100 100 L 300 100 L 200 300 z", 50 + 50j) self.assertEqual(path1, path2) + + def test_issue_99(self): + p = Path("M 100 250 S 200 200 200 250 300 300 300 250") + self.assertEqual(p.d(useSandT=True), 'M 100.0,250.0 S 200.0,200.0 200.0,250.0 S 300.0,300.0 300.0,250.0') + self.assertEqual(p.d(), + 'M 100.0,250.0 C 100.0,250.0 200.0,200.0 200.0,250.0 C 200.0,300.0 300.0,300.0 300.0,250.0') + self.assertNotEqual(p.d(), + 'M 100.0,250.0 C 100.0,250.0 200.0,200.0 200.0,250.0 C 200.0,250.0 300.0,300.0 300.0,250.0')