def testRemoveSimple(self): self.assertEqual(xmlEncoding.removeDeclaration( '<?xml version="1.0" encoding="utf-8"?>'), '<?xml version="1.0" ?>') self.assertEqual(xmlEncoding.removeDeclaration( "<?xml version='1.0' encoding='us-ascii' ?>"), "<?xml version='1.0' ?>")
def testNotRemoved(self): """Make sure that invalid, or missing, declarations aren't affected.""" for x in [ '<?xml encoding="utf-8"?>', # Missing version '<doc />', # No declaration ' <?xml version="1.0" encoding="utf-8"?>' # Space before declaration ]: self.assertEqual(xmlEncoding.removeDeclaration(x), x)