本文整理汇总了Python中xmlbuilder.XMLBuilder.very_child方法的典型用法代码示例。如果您正苦于以下问题:Python XMLBuilder.very_child方法的具体用法?Python XMLBuilder.very_child怎么用?Python XMLBuilder.very_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlbuilder.XMLBuilder
的用法示例。
在下文中一共展示了XMLBuilder.very_child方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestXMLBuilder
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import very_child [as 别名]
#.........这里部分代码省略.........
self.xml.t3('mmm')
eq_(str(self.xml), self.test_formatter1_res)
test_formatter2_res = '<root>\n\t<t1 m="1">\n\t\t<t2 />\n\t</t1>\n\t<t3>mmm</t3>\n</root>'
def test_formatter2(self):
self.xml['formatted'] = True
self.xml['tabstep'] = '\t'
self.xml.t1(m='1').t2
self.xml.t3('mmm')
eq_(str(self.xml), self.test_formatter2_res)
def test_attrib(self):
self.xml.t1(m='1').t2
self.xml.t3('mmm')
eq_(str(self.xml), '<root><t1 m="1"><t2 /></t1><t3>mmm</t3></root>')
def test_with1(self):
with self.xml.tree_root:
pass
eq_(str(self.xml), "<root><tree_root /></root>")
def test_with2(self):
with self.xml.tree_root('rr'):
pass
eq_(str(self.xml), "<root><tree_root>rr</tree_root></root>")
def test_with3(self):
with self.xml.tree_root(a='dt'):
pass
eq_(str(self.xml), '<root><tree_root a="dt" /></root>')
def test_with4(self):
with self.xml.tree_root('mm', a='dt'):
pass
eq_(str(self.xml), '<root><tree_root a="dt">mm</tree_root></root>')
def test_with5(self):
with self.xml.tree_root(a='dt'):
self.xml << '11'
eq_(str(self.xml), '<root><tree_root a="dt">11</tree_root></root>')
def test_with6(self):
with self.xml.tree_root(a='dt'):
self.xml << '11'
self.xml.tt
eq_(str(self.xml), '<root><tree_root a="dt">11<tt /></tree_root></root>')
def test_unicode(self):
with self.xml.tree_root(a=u'dt'):
self.xml << u'11'
self.xml.tt('12')
eq_(str(self.xml), u'<root><tree_root a="dt">11<tt>12</tt></tree_root></root>')
def test_unicode1(self):
with self.xml.tree_root(a=u'dt'):
self.xml << u'11'
self.xml.tt('12')
eq_(unicode(self.xml),
u'<root><tree_root a="dt">11<tt>12</tt></tree_root></root>')
def test_unicode2(self):
with self.xml.tree_root(a=u'dt'):
self.xml << u'бла-бла-бла'
self.xml.tt('12')
eq_(str(self.xml).decode('utf8'),
u'<root><tree_root a="dt">бла-бла-бла<tt>12</tt></tree_root></root>')
def test_with_all(self):
self.xml.top
with self.xml.tree_root('some data', attr='12'):
self.xml.child1
self.xml.child2('child data', attr='11')
with self.xml.tree_subroot(attr='13'):
self.xml.very_child('very data')
with self.xml.tree_subsubroot:
pass
eq_(str(self.xml), '<root>' +
'<top />' +
'<tree_root attr="12">some data' +
'<child1 />' +
'<child2 attr="11">child data</child2>' +
'<tree_subroot attr="13">' +
'<very_child>very data</very_child>'
'<tree_subsubroot />' +
'</tree_subroot>' +
'</tree_root>' +
'</root>')