Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def runTest(self):
options = ScourOptions
options.invalidOption = "invalid value"
try:
scourXmlFile('unittests/ids-to-strip.svg', options)
fail = False
except Exception:
fail = True
self.assertEqual(fail, False,
'Exception when calling Scour with invalid options')
def runTest(self):
doc = scourXmlFile('unittests/transform-translate-is-identity.svg')
self.assertEqual(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
'Transform containing identity translation not removed')
def runTest(self):
doc = scourXmlFile('unittests/groups-in-switch-with-id.svg',
parse_args(['--enable-id-stripping']))
self.assertEqual(doc.getElementsByTagName('g').length, 1,
'Erroneously removed a
def runTest(self):
doc = scourXmlFile('unittests/collapse-gradients-gradientUnits.svg')
self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'radialGradient')[0].getAttribute('gradientUnits'), '',
'gradientUnits not properly overrode when collapsing gradients')
def runTest(self):
doc = scourXmlFile('unittests/xml-space.svg')
self.assertNotEqual(doc.documentElement.getAttribute('xml:space'), '',
"'xml:space' attribute removed from root SVG element"
"when '--strip-xml-space' was NOT specified")
self.assertNotEqual(doc.getElementById('text1').getAttribute('xml:space'), '',
"'xml:space' attribute removed from a child element "
"when '--strip-xml-space' was NOT specified (should never be removed!)")
def runTest(self):
doc = scourXmlFile('unittests/path-truncate-zeros-calc.svg')
path = doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')
self.assertEqual(path, 'm5.81 0h0.1',
'Trailing zeros not removed from path data after calculation')
def runTest(self):
doc = scourXmlFile('unittests/unreferenced-radialGradient.svg')
self.assertEqual(len(doc.getElementsByTagNameNS(SVGNS, 'radialradient')), 0,
'Unreferenced radialGradient not removed')
def runTest(self):
svgdoc = scourXmlFile('unittests/remove-duplicate-gradients-master-without-id.svg')
lingrads = svgdoc.getElementsByTagNameNS(SVGNS, 'linearGradient')
rect = svgdoc.getElementById('r1')
self.assertEqual(1, lingrads.length,
'Duplicate linearGradient not removed')
self.assertEqual(lingrads[0].getAttribute("id"), "g1",
"linearGradient has a proper ID")
self.assertNotEqual(rect.getAttribute("fill"), "url(#)",
"linearGradient has a proper ID")
def runTest(self):
r = scourXmlFile('unittests/font-styles.svg').getElementsByTagNameNS(SVGNS, 'rect')[0]
self.assertEqual(r.getAttribute('font-size'), '',
'font-size not removed from rect')
def runTest(self):
p = scourXmlFile('unittests/path-with-closepath.svg').getElementsByTagNameNS(SVGNS, 'path')[0]
self.assertEqual(p.getAttribute('d'), 'm10 10h100v100h-100z',
'Path with closepath not preserved')