def testInvalidXmlUnexpectedTag(self): xml_stream = StringIO(""" <root> <sub1>text</sub1> </root> """) tag_root = xmlparser.Tag("root", xmlparser.SINGLE, None, [ xmlparser.Tag("sub", xmlparser.SINGLE, None, []), ]) self.assertRaises(xmlparser.ValidationError, xmlparser.parse, xml_stream, tag_root, {})
def testInvalidXmlTooManyTags(self): xml_stream = StringIO(""" <root> <a>some text</a> <a>some text</a> </root> """) tag_root = xmlparser.Tag("root", xmlparser.SINGLE, None, [ xmlparser.Tag("a", xmlparser.SINGLE, None, []), ]) self.assertRaises(xmlparser.ValidationError, xmlparser.parse, xml_stream, tag_root, {})
def testInvalidXmlAttribute(self): xml_stream = StringIO(""" <root foo="bar"> </root> """) tag_root = xmlparser.Tag("root", xmlparser.SINGLE, None, []) self.assertRaises(xmlparser.ValidationError, xmlparser.parse, xml_stream, tag_root, {})
def testIllFormedXml(self): xml_stream = StringIO(""" <root> <sub </root> """) tag_root = xmlparser.Tag("root", xmlparser.SINGLE, None, []) self.assertRaises(xml.sax.SAXException, xmlparser.parse, xml_stream, tag_root, {})