From 7cfb655cff2f8de590f733811d48bb0400895501 Mon Sep 17 00:00:00 2001 From: JSCHILL1 Date: Mon, 13 Apr 2009 12:14:22 -0500 Subject: [PATCH] Add remainder of Adobe namespaces and unit tests --- scour.py | 9 +++++++-- testscour.py | 35 +++++++++++++++++++++++++++++++++-- unittests/adobe.svg | 30 ++++++++++++++---------------- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/scour.py b/scour.py index 0e47bab..dd0961a 100755 --- a/scour.py +++ b/scour.py @@ -79,12 +79,17 @@ NS = { 'SVG': 'http://www.w3.org/2000/svg', 'ADOBE_SVG_VIEWER': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/', 'ADOBE_VARIABLES': 'http://ns.adobe.com/Variables/1.0/', 'ADOBE_SFW': 'http://ns.adobe.com/SaveForWeb/1.0/', - 'ADOBE_EXTENSIBILITY': 'http://ns.adobe.com/Extensibility/1.0/' + 'ADOBE_EXTENSIBILITY': 'http://ns.adobe.com/Extensibility/1.0/', + 'ADOBE_FLOWS': 'http://ns.adobe.com/Flows/1.0/', + 'ADOBE_IMAGE_REPLACEMENT': 'http://ns.adobe.com/ImageReplacement/1.0/', + 'ADOBE_CUSTOM': 'http://ns.adobe.com/GenericCustomNamespace/1.0/', + 'ADOBE_XPATH': 'http://ns.adobe.com/XPath/1.0/' } unwanted_ns = [ NS['SODIPODI'], NS['INKSCAPE'], NS['ADOBE_ILLUSTRATOR'], NS['ADOBE_GRAPHS'], NS['ADOBE_SVG_VIEWER'], NS['ADOBE_VARIABLES'], - NS['ADOBE_SFW'], NS['ADOBE_EXTENSIBILITY'] ] + NS['ADOBE_SFW'], NS['ADOBE_EXTENSIBILITY'], NS['ADOBE_FLOWS'], + NS['ADOBE_IMAGE_REPLACEMENT'], NS['ADOBE_CUSTOM'], NS['ADOBE_XPATH'] ] svgAttributes = [ 'clip-rule', diff --git a/testscour.py b/testscour.py index 77e4fd3..4e454fb 100755 --- a/testscour.py +++ b/testscour.py @@ -44,26 +44,57 @@ class NoSodipodiElements(unittest.TestCase): lambda e: e.namespaceURI != 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'), False, 'Found Sodipodi elements' ) -class NoAdobeElements(unittest.TestCase): +class NoAdobeIllustratorElements(unittest.TestCase): def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/AdobeIllustrator/10.0/'), False, 'Found Adobe Illustrator elements' ) +class NoAdobeGraphsElements(unittest.TestCase): + def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/Graphs/1.0/'), False, 'Found Adobe Graphs elements' ) +class NoAdobeSVGViewerElements(unittest.TestCase): + def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/'), False, 'Found Adobe SVG Viewer elements' ) +class NoAdobeVariablesElements(unittest.TestCase): + def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/Variables/1.0/'), False, 'Found Adobe Variables elements' ) +class NoAdobeSaveForWebElements(unittest.TestCase): + def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/SaveForWeb/1.0/'), False, 'Found Adobe Save For Web elements' ) +class NoAdobeExtensibilityElements(unittest.TestCase): + def runTest(self): self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, lambda e: e.namespaceURI != 'http://ns.adobe.com/Extensibility/1.0/'), False, 'Found Adobe Extensibility elements' ) - +class NoAdobeFlowsElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/Flows/1.0/'), False, + 'Found Adobe Flows elements' ) +class NoAdobeImageReplacementElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/ImageReplacement/1.0/'), False, + 'Found Adobe Image Replacement elements' ) +class NoAdobeCustomElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/GenericCustomNamespace/1.0/'), False, + 'Found Adobe Custom elements' ) +class NoAdobeXPathElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/XPath/1.0/'), False, + 'Found Adobe XPath elements' ) + + if __name__ == '__main__': unittest.main() diff --git a/unittests/adobe.svg b/unittests/adobe.svg index d5e676b..f5dba16 100644 --- a/unittests/adobe.svg +++ b/unittests/adobe.svg @@ -1,23 +1,21 @@ - - - - - - - - - - - - - -]> - + bar bar bar bar +bar +bar +bar +bar