def testWith(self): xml = XMLBuilder() with xml.root(lenght=12): pass self.assertEqual(str(xml), '<root lenght="12" />') xml = XMLBuilder() with xml.root(): xml << "text1" << "text2" << ('some_node', ) self.assertEqual(str(xml), "<root>text1text2<some_node /></root>")
def testWith(self): xml = XMLBuilder() with xml.root(lenght = 12): pass self.assertEqual(str(xml),'<root lenght="12" />') xml = XMLBuilder() with xml.root(): xml << "text1" << "text2" << ('some_node',) self.assertEqual(str(xml),"<root>text1text2<some_node /></root>")
def testFormat(self): x = XMLBuilder('utf-8', format=True) with x.root(): x << ('array', ) with x.array(len=10): with x.el(val=0): pass with x.el('xyz', val=1): pass x << ("el", "abc", {'val': 2}) << ('el', dict(val=3)) x << ('el', dict(val=4)) << ('el', dict(val='5')) with x('sup-el', val=23): x << "test " self.assertEqual(str(x), result1)
def testFormat(self): x = XMLBuilder('utf-8',format = True) with x.root(): x << ('array',) with x.array(len = 10): with x.el(val = 0): pass with x.el('xyz',val = 1): pass x << ("el","abc",{'val':2}) << ('el',dict(val=3)) x << ('el',dict(val=4)) << ('el',dict(val='5')) with x('sup-el',val = 23): x << "test " self.assertEqual(str(x),result1)