Prevent removal of metadata elements if they have only text nodes. Also added some unit tests.
This commit is contained in:
parent
7cfb655cff
commit
2cc9c00ef7
7 changed files with 58 additions and 4 deletions
24
testscour.py
24
testscour.py
|
|
@ -95,6 +95,30 @@ class NoAdobeXPathElements(unittest.TestCase):
|
|||
lambda e: e.namespaceURI != 'http://ns.adobe.com/XPath/1.0/'), False,
|
||||
'Found Adobe XPath elements' )
|
||||
|
||||
#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 DoNotRemoveMetadataWithOnlyText(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/metadata-with-text.svg')
|
||||
self.assertEquals(len(doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'metadata')), 1,
|
||||
'Removed metadata element with only text child' )
|
||||
|
||||
class RemoveEmptyMetadataElement(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/empty-metadata.svg')
|
||||
self.assertEquals(len(doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'metadata')), 0,
|
||||
'Did not remove empty metadata element' )
|
||||
|
||||
class RemoveEmptyGElements(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/empty-g.svg')
|
||||
self.assertEquals(len(doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'g')), 1,
|
||||
'Did not remove empty g element' )
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue