Add unittest for --strip-xml-space

This commit is contained in:
Eduard Braun 2016-09-17 17:11:44 +02:00
parent 24c8087bd4
commit 47cfb9aa0e
2 changed files with 31 additions and 1 deletions

View file

@ -2100,7 +2100,33 @@ class ParseStyleAttribute(unittest.TestCase):
doc = scourXmlFile('unittests/style.svg') doc = scourXmlFile('unittests/style.svg')
self.assertEqual(doc.documentElement.getAttribute('style'), self.assertEqual(doc.documentElement.getAttribute('style'),
'property1:value1;property2:value2;property3:value3', 'property1:value1;property2:value2;property3:value3',
'Style attribute not properly parsed and/or serialized') "Style attribute not properly parsed and/or serialized")
class StripXmlSpaceAttribute(unittest.TestCase):
def runTest(self):
doc = scourXmlFile('unittests/xml-space.svg',
parse_args(['--strip-xml-space']))
self.assertEqual(doc.documentElement.getAttribute('xml:space'), '',
"'xml:space' attribute not removed from root SVG element"
"when '--strip-xml-space' was specified")
self.assertNotEqual(doc.getElementById('text1').getAttribute('xml:space'), '',
"'xml:space' attribute removed from a child element"
"when '--strip-xml-space' was specified (should only operate on root SVG element)")
class DoNotStripXmlSpaceAttribute(unittest.TestCase):
def runTest(self):
doc = scourXmlFile('unittests/xml-space.svg')
self.assertNotEqual(doc.documentElement.getAttribute('xml:space'), '',
"'xml:space' attribute removed from root SVG element"
"when '--strip-xml-space' was NOT specified")
self.assertNotEqual(doc.getElementById('text1').getAttribute('xml:space'), '',
"'xml:space' attribute removed from a child element"
"when '--strip-xml-space' was NOT specified (should never be removed!)")
# TODO: write tests for --enable-viewboxing # TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters # TODO; write a test for embedding rasters

4
unittests/xml-space.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="50" xml:space="preserve">
<text id="text1" x="5" y="20" xml:space="preserve">Some random text.</text>
</svg>

After

Width:  |  Height:  |  Size: 210 B