From ef0f1fe664e6f183a42112f496db9c55b87a8d38 Mon Sep 17 00:00:00 2001 From: JSCHILL1 Date: Mon, 13 Apr 2009 11:38:00 -0500 Subject: [PATCH] Added sodipodi element unit test --- testscour.py | 15 +++++++++------ unittests/sodipodi.svg | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 unittests/sodipodi.svg diff --git a/testscour.py b/testscour.py index ffd4ef3..d1d511c 100755 --- a/testscour.py +++ b/testscour.py @@ -21,8 +21,8 @@ import unittest import scour import xml.dom.minidom -# performs a test on a given node -# func must return either True or False +# helper function that performs a test on a given node and all its children +# func must return either True (if pass) or False (if fail) def walkTree(elem, func): if func(elem) == False: return False for child in elem.childNodes: @@ -31,12 +31,15 @@ def walkTree(elem, func): class NoInkscapeElements(unittest.TestCase): def runTest(self): - doc = scour.scourXmlFile('unittests/inkscape.svg') - self.assertNotEquals( walkTree( doc.documentElement, + self.assertNotEquals(walkTree( scour.scourXmlFile('unittests/sodipodi.svg').documentElement, lambda e: e.namespaceURI != "http://www.inkscape.org/namespaces/inkscape" ), False, 'Found Inkscape elements' ) +class NoSodipodiElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree( scour.scourXmlFile('unittests/sodipodi.svg').documentElement, + lambda e: e.namespaceURI != "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" ), False, + 'Found Sodipodi elements' ) + if __name__ == '__main__': unittest.main() - -print "done" \ No newline at end of file diff --git a/unittests/sodipodi.svg b/unittests/sodipodi.svg new file mode 100644 index 0000000..22d93eb --- /dev/null +++ b/unittests/sodipodi.svg @@ -0,0 +1,5 @@ + + + + +