本文整理汇总了Python中frontik.doc.Doc.to_etree_element方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.to_etree_element方法的具体用法?Python Doc.to_etree_element怎么用?Python Doc.to_etree_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frontik.doc.Doc
的用法示例。
在下文中一共展示了Doc.to_etree_element方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_future_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_future_simple(self):
d = Doc('a')
f = Future()
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a/>""")
f.set_result('test')
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>test</a>""")
示例2: test_future_etree_element
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_future_etree_element(self):
d = Doc('a')
f = Future()
f.set_result(etree.Element('b'))
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a><b/></a>""")
示例3: test_root_node
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_root_node(self):
d = Doc(root_node=etree.Element('doc'))
d.put(etree.Element('test1'))
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<doc><test1/></doc>"""
)
示例4: test_future_list
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_future_list(self):
d = Doc('a')
f = Future()
f.set_result([etree.Comment('ccc'), etree.Element('bbb')])
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0'?>\n<a><!--ccc--><bbb/></a>""")
示例5: test_doc_nested
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_doc_nested(self):
a = Doc('a')
b = Doc('b')
a.put(b)
self.assertXmlEqual(
a.to_etree_element(), b"""<?xml version='1.0' encoding='utf-8'?>\n<a><b/></a>"""
)
示例6: test_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_simple(self):
d = Doc('a')
self.assertTrue(d.is_empty())
d.put('test')
self.assertFalse(d.is_empty())
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>test</a>""")
示例7: test_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_simple(self):
d = Doc('a')
self.assertTrue(d.is_empty())
d.put(None)
self.assertXmlEqual(d.to_etree_element(), b'<a/>')
node = etree.Element('b')
node.text = 'тест'
d.put(node)
self.assertFalse(d.is_empty())
self.assertXmlEqual(
d.to_etree_element(),
b"""<?xml version='1.0' encoding='utf-8'?>\n<a><b>\xd1\x82\xd0\xb5\xd1\x81\xd1\x82</b></a>"""
)
示例8: test_root_node_doc
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_root_node_doc(self):
d1 = Doc('a')
d1.put(etree.Comment('1'))
d2 = Doc(root_node=d1)
d2.put(etree.Comment('2'))
self.assertXmlEqual(
d2.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a><!--1--><!--2--></a>"""
)
示例9: test_failed_future
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_failed_future(self):
d = Doc('a')
f = Future()
result = self.get_test_request_result()
result._data_parse_error = DataParseError(reason='error', code='code')
f.set_result(result)
d.put(f)
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0'?>\n<a><error reason="error" code="code"/></a>"""
)
示例10: test_nodes_and_text
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_nodes_and_text(self):
a = Doc('a')
a.put('1')
a.put(Doc('b'))
a.put('2')
a.put(Doc('c'))
a.put('3')
self.assertXmlAlmostEqual(
a.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>1<b/>2<c/>3</a>"""
)
示例11: test_future_string_value
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_future_string_value(self):
d = Doc('a')
f = Future()
result = self.get_test_request_result()
result._content_type = 'text'
result._data = 'plain_text'
f.set_result(result)
d.put(f)
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0'?>\n<a></a>"""
)
示例12: test_string_as_root_node
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import to_etree_element [as 别名]
def test_string_as_root_node(self):
d = Doc(root_node='a')
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a></a>""")