add unit tests
This commit is contained in:
parent
d710fb3f6c
commit
6a23a4cd71
2 changed files with 17 additions and 2 deletions
|
|
@ -2884,9 +2884,11 @@ def scourString(in_string, options=None):
|
||||||
# flowRoot elements don't render at all on current browsers (04/2016)
|
# flowRoot elements don't render at all on current browsers (04/2016)
|
||||||
cnt_flowText_el = len(doc.getElementsByTagName('flowRoot'))
|
cnt_flowText_el = len(doc.getElementsByTagName('flowRoot'))
|
||||||
if cnt_flowText_el:
|
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:
|
if options.error_on_flowtext:
|
||||||
sys.exit(1)
|
raise Exception(errmsg)
|
||||||
|
else:
|
||||||
|
print("WARNING: {}".format(errmsg))
|
||||||
|
|
||||||
# remove <metadata> if the user wants to
|
# remove <metadata> if the user wants to
|
||||||
if options.remove_metadata:
|
if options.remove_metadata:
|
||||||
|
|
|
||||||
13
testscour.py
13
testscour.py
|
|
@ -1416,6 +1416,19 @@ class DuplicateGradientsUpdateStyle(unittest.TestCase):
|
||||||
self.assertEqual('fill:url(#' + gradientTag.getAttribute('id') + ')', rectTag1.getAttribute('style'),
|
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')
|
'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 tests for --enable-viewboxing
|
||||||
# TODO; write a test for embedding rasters
|
# TODO; write a test for embedding rasters
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue