Added tests for inkscape and sodipodi namespace declarations and attributes
This commit is contained in:
parent
f6387b1f22
commit
72363ec24b
4 changed files with 47 additions and 11 deletions
2
scour.py
2
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
|
||||
|
|
|
|||
48
testscour.py
48
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__':
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:foo="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="0.46" version="1.0">
|
||||
<inkscape:perspective inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective3104"/>
|
||||
<rect width="300" height="200" fill="green" inkscape:collect="always"/>
|
||||
<rect width="300" height="200" fill="green" inkscape:collect="always" foo:bar="1"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 489 B |
|
|
@ -1,5 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:version="0.32">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:foo="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:version="0.32">
|
||||
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10"/>
|
||||
<rect width="300" height="200" fill="green" />
|
||||
<rect width="300" height="200" fill="green" sodipodi:bar="1" foo:baz="1"/>
|
||||
</svg>
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 485 B |
Loading…
Add table
Add a link
Reference in a new issue