From 8d7220c2228007a770006c9f4608dafb3fa5846c Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 17 May 2017 21:01:51 +0200 Subject: [PATCH] Unittests: Complete set of tests checking the removal of empty line segments if round / square linecaps are present (or not) --- testscour.py | 23 ++++++++++++++++------- unittests/path-with-caps.svg | 8 +++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/testscour.py b/testscour.py index 250fe23..f5818e6 100755 --- a/testscour.py +++ b/testscour.py @@ -1036,16 +1036,25 @@ class RemoveEmptyLineSegmentsFromPath(unittest.TestCase): self.assertEqual(path[4][0], 'z', 'Did not remove an empty line segment from path') -# Do not remove empty segments if round linecaps. - -class DoNotRemoveEmptySegmentsFromPathWithRoundLineCaps(unittest.TestCase): +class RemoveEmptySegmentsFromPathWithButtLineCaps(unittest.TestCase): def runTest(self): - doc = scourXmlFile('unittests/path-with-caps.svg') - path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) - self.assertEqual(len(path), 2, - 'Did not preserve empty segments when path had round linecaps') + doc = scourXmlFile('unittests/path-with-caps.svg', parse_args(['--disable-style-to-xml'])) + for id in ['none', 'attr_butt', 'style_butt']: + path = svg_parser.parse(doc.getElementById(id).getAttribute('d')) + self.assertEqual(len(path), 1, + 'Did not remove empty segments when path had butt linecaps') + + +class DoNotRemoveEmptySegmentsFromPathWithRoundSquareLineCaps(unittest.TestCase): + + def runTest(self): + doc = scourXmlFile('unittests/path-with-caps.svg', parse_args(['--disable-style-to-xml'])) + for id in ['attr_round', 'attr_square', 'style_round', 'style_square']: + path = svg_parser.parse(doc.getElementById(id).getAttribute('d')) + self.assertEqual(len(path), 2, + 'Did remove empty segments when path had round or square linecaps') class ChangeLineToHorizontalLineSegmentInPath(unittest.TestCase): diff --git a/unittests/path-with-caps.svg b/unittests/path-with-caps.svg index 0e7ab1a..3c24163 100644 --- a/unittests/path-with-caps.svg +++ b/unittests/path-with-caps.svg @@ -1,4 +1,10 @@ - + + + + + + +