From 47cfb9aa0e2120a5a0c2be995eb04ab8aa3203fa Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 17 Sep 2016 17:11:44 +0200 Subject: [PATCH] Add unittest for `--strip-xml-space` --- testscour.py | 28 +++++++++++++++++++++++++++- unittests/xml-space.svg | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 unittests/xml-space.svg diff --git a/testscour.py b/testscour.py index cd0c59e..9878b01 100755 --- a/testscour.py +++ b/testscour.py @@ -2100,7 +2100,33 @@ class ParseStyleAttribute(unittest.TestCase): doc = scourXmlFile('unittests/style.svg') self.assertEqual(doc.documentElement.getAttribute('style'), '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 a test for embedding rasters diff --git a/unittests/xml-space.svg b/unittests/xml-space.svg new file mode 100644 index 0000000..88a9f50 --- /dev/null +++ b/unittests/xml-space.svg @@ -0,0 +1,4 @@ + + + Some random text. + \ No newline at end of file