本文整理汇总了Python中genshi.input.XML.render方法的典型用法代码示例。如果您正苦于以下问题:Python XML.render方法的具体用法?Python XML.render怎么用?Python XML.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.input.XML
的用法示例。
在下文中一共展示了XML.render方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def _test(self, expected_id, result):
expected = self._expected(expected_id).render(encoding='utf-8')
result = XML(result.render(encoding='utf-8')).render(encoding='utf-8')
expected, result = expected.splitlines(), result.splitlines()
for exp, res in zip(expected, result):
self.assertEquals(exp, res)
self.assertEquals(len(expected), len(result))
示例2: test_pickle
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_pickle(self):
xml = XML('<li>Foo</li>')
buf = BytesIO()
pickle.dump(xml, buf, 2)
buf.seek(0)
xml = pickle.load(buf)
self.assertEquals('<li>Foo</li>', xml.render(encoding=None))
示例3: test_pickle
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_pickle(self):
xml = XML('<li>Foo</li>')
buf = StringIO()
pickle.dump(xml, buf, 2)
buf.seek(0)
xml = pickle.load(buf)
self.assertEquals('<li>Foo</li>', xml.render())
示例4: test_pre_whitespace
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_pre_whitespace(self):
content = '\nHey <em>there</em>. \n\n I am indented.\n'
stream = XML('<pre>%s</pre>' % content)
output = stream.render(HTMLSerializer, encoding=None)
self.assertEqual('<pre>%s</pre>' % content, output)
示例5: test_textarea_whitespace
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_textarea_whitespace(self):
content = '\nHey there. \n\n I am indented.\n'
stream = XML('<textarea name="foo">%s</textarea>' % content)
output = stream.render(HTMLSerializer, encoding=None)
self.assertEqual('<textarea name="foo">%s</textarea>' % content, output)
示例6: test_render_output_stream_unicode
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_output_stream_unicode(self):
xml = XML('<li>Über uns</li>')
strio = StringIO()
self.assertEqual(None, xml.render(encoding=None, out=strio))
self.assertEqual(u'<li>Über uns</li>', strio.getvalue())
示例7: test_render_output_stream_utf8
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_output_stream_utf8(self):
xml = XML('<li>Über uns</li>')
strio = cStringIO()
self.assertEqual(None, xml.render(out=strio))
self.assertEqual('<li>Über uns</li>', strio.getvalue())
示例8: test_render_ascii
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_ascii(self):
xml = XML('<li>Über uns</li>')
self.assertEqual('<li>Über uns</li>', xml.render(encoding='ascii'))
示例9: test_render_unicode
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_unicode(self):
xml = XML('<li>Über uns</li>')
self.assertEqual(u'<li>Über uns</li>', xml.render(encoding=None))
示例10: test_render_utf8
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_utf8(self):
xml = XML('<li>Über uns</li>')
self.assertEqual('<li>Über uns</li>', xml.render())
示例11: test_render_output_stream_utf8
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_output_stream_utf8(self):
xml = XML('<li>Über uns</li>')
strio = BytesIO()
self.assertEqual(None, xml.render(encoding='utf-8', out=strio))
self.assertEqual(u'<li>Über uns</li>'.encode('utf-8'), strio.getvalue())
示例12: test_render_utf8
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_utf8(self):
xml = XML('<li>Über uns</li>')
self.assertEqual(u'<li>Über uns</li>'.encode('utf-8'), xml.render(encoding='utf-8'))
示例13: test_render_ascii
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_ascii(self):
xml = XML("<li>Über uns</li>")
self.assertEqual(u"<li>Über uns</li>".encode("ascii"), xml.render(encoding="ascii"))
示例14: test_render_unicode
# 需要导入模块: from genshi.input import XML [as 别名]
# 或者: from genshi.input.XML import render [as 别名]
def test_render_unicode(self):
xml = XML("<li>Über uns</li>")
self.assertEqual(u"<li>Über uns</li>", xml.render())
self.assertEqual(u"<li>Über uns</li>", xml.render(encoding=None))