本文整理汇总了Python中xml.sax.expatreader方法的典型用法代码示例。如果您正苦于以下问题:Python sax.expatreader方法的具体用法?Python sax.expatreader怎么用?Python sax.expatreader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml.sax
的用法示例。
在下文中一共展示了sax.expatreader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_basic
# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import expatreader [as 别名]
def test_filter_basic(self):
result = StringIO()
gen = XMLGenerator(result)
filter = XMLFilterBase()
filter.setContentHandler(gen)
filter.startDocument()
filter.startElement("doc", {})
filter.characters("content")
filter.ignorableWhitespace(" ")
filter.endElement("doc")
filter.endDocument()
self.assertEqual(result.getvalue(), start + "<doc>content </doc>")
# ===========================================================================
#
# expatreader tests
#
# ===========================================================================
示例2: test_make_parser
# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import expatreader [as 别名]
def test_make_parser(self):
# Creating a parser should succeed - it should fall back
# to the expatreader
p = make_parser(['xml.parsers.no_such_parser'])
示例3: test_sf_1511497
# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import expatreader [as 别名]
def test_sf_1511497(self):
# Bug report: http://www.python.org/sf/1511497
import sys
old_modules = sys.modules.copy()
for modname in sys.modules.keys():
if modname.startswith("xml."):
del sys.modules[modname]
try:
import xml.sax.expatreader
module = xml.sax.expatreader
self.assertEqual(module.__name__, "xml.sax.expatreader")
finally:
sys.modules.update(old_modules)
示例4: test_make_parser
# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import expatreader [as 别名]
def test_make_parser(self):
# Creating a parser should succeed - it should fall back
# to the expatreader
p = make_parser(['xml.parsers.no_such_parser'])
# ===== XMLGenerator