diff --git a/scour/scour.py b/scour/scour.py index 4d7995e..0112ad1 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -2884,9 +2884,11 @@ def scourString(in_string, options=None): # flowRoot elements don't render at all on current browsers (04/2016) cnt_flowText_el = len(doc.getElementsByTagName('flowRoot')) if cnt_flowText_el: - print("SVG input document uses {} flow text elements, which won't render on browsers!".format(cnt_flowText_el)) + errmsg = "SVG input document uses {} flow text elements, which won't render on browsers!".format(cnt_flowText_el) if options.error_on_flowtext: - sys.exit(1) + raise Exception(errmsg) + else: + print("WARNING: {}".format(errmsg)) # remove if the user wants to if options.remove_metadata: diff --git a/testscour.py b/testscour.py index de8036f..af9ce96 100755 --- a/testscour.py +++ b/testscour.py @@ -1416,6 +1416,19 @@ class DuplicateGradientsUpdateStyle(unittest.TestCase): self.assertEqual('fill:url(#' + gradientTag.getAttribute('id') + ')', rectTag1.getAttribute('style'), 'Either of #duplicate-one or #duplicate-two was removed, but style="fill:" was not updated to reflect this') +class DocWithFlowtext(unittest.TestCase): + def runTest(self): + with self.assertRaises(Exception): + scour.scourXmlFile('unittests/flowtext.svg', + scour.parse_args(['--error-on-flowtext'])[0]) + +class DocWithNoFlowtext(unittest.TestCase): + def runTest(self): + try: + scour.scourXmlFile('unittests/flowtext-less.svg', + scour.parse_args(['--error-on-flowtext'])[0]) + except Exception as e: + self.fail("exception '{}' was raised, and we didn't expect that!".format(e)) # TODO: write tests for --enable-viewboxing # TODO; write a test for embedding rasters