diff --git a/scour.py b/scour.py index f06c4f7..5a32f43 100755 --- a/scour.py +++ b/scour.py @@ -50,7 +50,7 @@ # - Convert all colors to #RRGGBB format # - Reduce #RRGGBB format to #RGB format when possible # - rework command-line argument processing so that options are configurable -https://bugs.edge.launchpad.net/ubuntu/+source/human-icon-theme/+bug/361667/ +# https://bugs.edge.launchpad.net/ubuntu/+source/human-icon-theme/+bug/361667/ # Some notes to not forget: # - removing unreferenced IDs loses some semantic information diff --git a/testscour.py b/testscour.py index 56bb296..2a5c16b 100755 --- a/testscour.py +++ b/testscour.py @@ -153,13 +153,47 @@ class RemoveDuplicateRadialGradientStops(unittest.TestCase): self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3, 'Duplicate radial gradient stops not removed' ) -# These tests will fail at present -#class NoInkscapeAttributes(unittest.TestCase): -# def runTest(self): -# self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/inkscape.svg').documentElement, -# lambda e: for a in e.attributes: a.namespaceURI -# False, -# 'Found Inkscape attributes') +class NoSodipodiNamespaceDecl(unittest.TestCase): + def runTest(self): + attrs = scour.scourXmlFile('unittests/sodipodi.svg').documentElement.attributes + for i in range(len(attrs)): + self.assertNotEquals(attrs.item(i).nodeValue, + 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', + 'Sodipodi namespace declaration found' ) + +class NoInkscapeNamespaceDecl(unittest.TestCase): + def runTest(self): + attrs = scour.scourXmlFile('unittests/inkscape.svg').documentElement.attributes + for i in range(len(attrs)): + self.assertNotEquals(attrs.item(i).nodeValue, + 'http://www.inkscape.org/namespaces/inkscape', + 'Inkscape namespace declaration found' ) + +class NoSodipodiAttributes(unittest.TestCase): + def runTest(self): + def findSodipodiAttr(elem): + attrs = elem.attributes + if attrs == None: return True + for i in range(len(attrs)): + if attrs.item(i).namespaceURI == 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd': + return False + return True + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/sodipodi.svg').documentElement, + findSodipodiAttr), False, + 'Found Sodipodi attributes' ) + +class NoInkscapeAttributes(unittest.TestCase): + def runTest(self): + def findInkscapeAttr(elem): + attrs = elem.attributes + if attrs == None: return True + for i in range(len(attrs)): + if attrs.item(i).namespaceURI == 'http://www.inkscape.org/namespaces/inkscape': + return False + return True + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/inkscape.svg').documentElement, + findInkscapeAttr), False, + 'Found Inkscape attributes' ) if __name__ == '__main__': diff --git a/unittests/inkscape.svg b/unittests/inkscape.svg index 1ce1a80..3749343 100644 --- a/unittests/inkscape.svg +++ b/unittests/inkscape.svg @@ -1,5 +1,6 @@ - + \ No newline at end of file diff --git a/unittests/sodipodi.svg b/unittests/sodipodi.svg index 22d93eb..9fa3c5b 100644 --- a/unittests/sodipodi.svg +++ b/unittests/sodipodi.svg @@ -1,5 +1,6 @@ - + - +