def test_builder_method_with_illegal_object(self): try: xml4h.build(123) except Exception, ex: self.assertEqual(xml4h.exceptions.IncorrectArgumentTypeException, ex.__class__) self.assertEqual( u"Argument 123 is not one of the expected types: " u"[<type 'basestring'>, <class 'xml4h.nodes.Element'>]", unicode(ex))
def test_builder_method_with_illegal_object(self): try: xml4h.build(123) except Exception, ex: self.assertEqual( xml4h.exceptions.IncorrectArgumentTypeException, ex.__class__) self.assertEqual( u"Argument 123 is not one of the expected types: " u"[<type 'basestring'>, <class 'xml4h.nodes.Element'>]", unicode(ex))
def to_xml(self): attrs = {"xmlns": "http://www.w3.org/2000/svg", "version": "1.1", "width": px(self.width), "height": px(self.height)} xml = xml4h.build("svg").attributes(attrs) for child in self.children: child.to_xml(xml) io = StringIO() xml.write(writer = io) return io.getvalue()
def xml4h_test1(): root = xml4h.build('root') \ .e('level1') \ .e('level2').t('text') \ .up() \ .e('level2').t('">="') \ .up() \ .up() # .up() print(root.xml_doc()) pass
def xml4h_test2(): xml4h.write_node = override_write_node root = xml4h.build('root') \ .e('level1') \ .e('level2').t('text') \ .up() \ .e('level2').t('">="') \ .up() \ .up() # .up() print(root.xml_doc()) pass
def test_create_minidom(self): xmlb = xml4h.build('DocRoot', adapter=xml4h.XmlDomImplAdapter) self.assertIsInstance(xmlb.dom_element.impl_document, xml.dom.minidom.Document)
def test_create_minidom(self): xmlb = xml4h.build('DocRoot', adapter=xml4h.XmlDomImplAdapter) self.assertIsInstance( xmlb.dom_element.impl_document, xml.dom.minidom.Document)