Ejemplo n.º 1
0
 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, {})
Ejemplo n.º 2
0
 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, {})
Ejemplo n.º 3
0
 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, {})
Ejemplo n.º 4
0
 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, {})