Modified scour and added first unit test
This commit is contained in:
parent
a1f6d9e8dd
commit
8d598b20f2
3 changed files with 35 additions and 3 deletions
19
testscour.py
19
testscour.py
|
|
@ -19,5 +19,24 @@
|
|||
|
||||
import unittest
|
||||
import scour
|
||||
import xml.dom.minidom
|
||||
|
||||
# performs a test on a given node
|
||||
# func must return either True or False
|
||||
def walkTree(elem, func):
|
||||
if func(elem) == False: return False
|
||||
for child in elem.childNodes:
|
||||
if walkTree(child, func) == False: return False
|
||||
return True
|
||||
|
||||
class NoInkscapeElements(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/inkscape.svg')
|
||||
self.assertNotEquals( walkTree( doc.documentElement,
|
||||
lambda e: e.namespaceURI != "http://www.inkscape.org/namespaces/inkscape" ), False,
|
||||
'Found Inkscape elements' )
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
print "done"
|
||||
Loading…
Add table
Add a link
Reference in a new issue