How to use the scour.scour.parse_args function in scour

To help you get started, we’ve selected a few scour examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scour-project / scour / test_scour.py View on Github external
def test_disable_embed_rasters(self):
        doc = scourXmlFile('unittests/raster-formats.svg',
                           parse_args(['--disable-embed-rasters']))
        self.assertEqual(doc.getElementById('png').getAttribute('xlink:href'), 'raster.png',
                         "Raster image embedded when '--disable-embed-rasters' was specified")
github scour-project / scour / test_scour.py View on Github external
def runTest(self):
        with open('unittests/style-cdata.svg') as f:
            docStr = f.read()
        docStr = scourString(docStr,
                             parse_args(['--shorten-ids']))
        self.assertEqual(docStr.find('somethingreallylong'), -1,
                         'Did not shorten IDs in the internal stylesheet')
github scour-project / scour / test_scour.py View on Github external
def test_protect_ids_prefix(self):
        doc = scourXmlFile('unittests/ids-protect.svg',
                           parse_args(['--enable-id-stripping', '--protect-ids-prefix=my']))
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[0].getAttribute('id'), '',
                         "ID 'text1' should have been stripped despite '--protect-ids-prefix' being specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[1].getAttribute('id'), '',
                         "ID 'text2' should have been stripped despite '--protect-ids-prefix' being specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[2].getAttribute('id'), '',
                         "ID 'text3' should have been stripped despite '--protect-ids-prefix' being specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[3].getAttribute('id'), '',
                         "ID 'text_custom' should have been stripped despite '--protect-ids-prefix' being specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[4].getAttribute('id'), 'my_text1',
                         "ID 'my_text1' should NOT have been stripped because of '--protect-ids-prefix'")
github scour-project / scour / test_scour.py View on Github external
def runTest(self):
        doc = scourXmlFile('unittests/duplicate-gradients-update-style.svg',
                           parse_args(['--disable-style-to-xml']))
        gradient = doc.getElementsByTagName('linearGradient')[0]
        rects = doc.getElementsByTagName('rect')
        self.assertEqual('fill:url(#' + gradient.getAttribute('id') + ')', rects[0].getAttribute('style'),
                         'Either of #duplicate-one or #duplicate-two was removed, '
                         'but style="fill:" was not updated to reflect this')
        self.assertEqual('fill:url(#' + gradient.getAttribute('id') + ')', rects[1].getAttribute('style'),
                         'Either of #duplicate-one or #duplicate-two was removed, '
                         'but style="fill:" was not updated to reflect this')
        self.assertEqual('fill:url(#' + gradient.getAttribute('id') + ') #fff', rects[2].getAttribute('style'),
                         'Either of #duplicate-one or #duplicate-two was removed, '
                         'but style="fill:" (with fallback) was not updated to reflect this')
github scour-project / scour / test_scour.py View on Github external
def test_viewbox_remove_width_and_height(self):
        doc = scourXmlFile('unittests/viewbox-remove.svg', parse_args(['--enable-viewboxing']))
        width = doc.documentElement.getAttribute('width')
        height = doc.documentElement.getAttribute('height')
        self.assertEqual(width, '', "width not removed with '--enable-viewboxing'.")
        self.assertEqual(height, '', "height not removed with '--enable-viewboxing'.")
github scour-project / scour / test_scour.py View on Github external
def test_sibling_merge(self):
        doc = scourXmlFile('unittests/group-sibling-merge.svg',
                           parse_args([]))
        self.assertEqual(doc.getElementsByTagName('g').length, 5,
                         'Merged sibling 
github scour-project / scour / test_scour.py View on Github external
def test_output_spaces_with_renderer_workaround(self):
        doc = scourXmlFile('unittests/path-elliptical-flags.svg', parse_args(['--renderer-workaround']))
        paths = doc.getElementsByTagNameNS(SVGNS, 'path')
        for path in paths:
            self.assertEqual(path.getAttribute('d'), 'm0 0a100 50 0 0 0 100 50',
                             'Did not output spaces after boolean flags in elliptical arg path command '
                             'with renderer workaround')
github scour-project / scour / test_scour.py View on Github external
def test_protect_none(self):
        doc = scourXmlFile('unittests/ids-protect.svg',
                           parse_args(['--enable-id-stripping']))
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[0].getAttribute('id'), '',
                         "ID 'text1' not stripped when none of the '--protect-ids-_' options was specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[1].getAttribute('id'), '',
                         "ID 'text2' not stripped when none of the '--protect-ids-_' options was specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[2].getAttribute('id'), '',
                         "ID 'text3' not stripped when none of the '--protect-ids-_' options was specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[3].getAttribute('id'), '',
                         "ID 'text_custom' not stripped when none of the '--protect-ids-_' options was specified")
        self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'text')[4].getAttribute('id'), '',
                         "ID 'my_text1' not stripped when none of the '--protect-ids-_' options was specified")