本文整理匯總了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