From 32e7e5517f48cf9a9c324c74927acb5ff4ce8855 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 7 Dec 2015 00:27:25 +0100 Subject: [PATCH] Unittests: Account for b979fe19e563a559d03f15da818f95ddff00bc56 (fix one test and add two more) - Unused XML namespace declarations *are supposed* to be removed - XML namespace declarations that are used as prefix for elements/attributes *must not* be removed --- testscour.py | 20 +++++++++++++++++--- unittests/xml-well-formed.svg | 4 +++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/testscour.py b/testscour.py index 98c357b..7b29bdf 100755 --- a/testscour.py +++ b/testscour.py @@ -931,12 +931,26 @@ class WellFormedXMLAmpersandInTextContent(unittest.TestCase): self.assertTrue( wellformed.find('Peanut Butter & Jelly') != -1, 'Improperly serialized & in text content') -class WellFormedXMLNamespacePrefix(unittest.TestCase): +class WellFormedXMLNamespacePrefixRemoveUnused(unittest.TestCase): def runTest(self): with open('unittests/xml-well-formed.svg') as f: wellformed = scour.scourString(f.read()) - self.assertTrue( wellformed.find('xmlns:foo=') != -1, - 'Improperly serialized namespace prefix declarations') + self.assertTrue( wellformed.find('xmlns:foo=') == -1, + 'Improperly serialized namespace prefix declarations: Unused namespace decaration not removed') + +class WellFormedXMLNamespacePrefixKeepUsedElementPrefix(unittest.TestCase): + def runTest(self): + with open('unittests/xml-well-formed.svg') as f: + wellformed = scour.scourString(f.read()) + self.assertTrue( wellformed.find('xmlns:bar=') != -1, + 'Improperly serialized namespace prefix declarations: Used element prefix removed') + +class WellFormedXMLNamespacePrefixKeepUsedAttributePrefix(unittest.TestCase): + def runTest(self): + with open('unittests/xml-well-formed.svg') as f: + wellformed = scour.scourString(f.read()) + self.assertTrue( wellformed.find('xmlns:baz=') != -1, + 'Improperly serialized namespace prefix declarations: Used attribute prefix removed') class NamespaceDeclPrefixesInXMLWhenNotInDefaultNamespace(unittest.TestCase): def runTest(self): diff --git a/unittests/xml-well-formed.svg b/unittests/xml-well-formed.svg index 705a288..5c8d706 100644 --- a/unittests/xml-well-formed.svg +++ b/unittests/xml-well-formed.svg @@ -1,9 +1,11 @@ - + 2 < 5 Peanut Butter & Jelly + + ΉTML & CSS