本文整理汇总了Python中test.support.import_fresh_module方法的典型用法代码示例。如果您正苦于以下问题:Python support.import_fresh_module方法的具体用法?Python support.import_fresh_module怎么用?Python support.import_fresh_module使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.support
的用法示例。
在下文中一共展示了support.import_fresh_module方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_fresh_module
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import import_fresh_module [as 别名]
def test_import_fresh_module(self):
support.import_fresh_module("ftplib")
示例2: testWithoutThreading
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import import_fresh_module [as 别名]
def testWithoutThreading(self):
module = support.import_fresh_module("bz2", blocked=("threading",))
with module.BZ2File(self.filename, "wb") as f:
f.write(b"abc")
with module.BZ2File(self.filename, "rb") as f:
self.assertEqual(f.read(), b"abc")
示例3: import_importlib
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import import_fresh_module [as 别名]
def import_importlib(module_name):
"""Import a module from importlib both w/ and w/o _frozen_importlib."""
fresh = ('importlib',) if '.' in module_name else ()
frozen = support.import_fresh_module(module_name)
source = support.import_fresh_module(module_name, fresh=fresh,
blocked=('_frozen_importlib', '_frozen_importlib_external'))
return {'Frozen': frozen, 'Source': source}
示例4: import_importlib
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import import_fresh_module [as 别名]
def import_importlib(module_name):
"""Import a module from importlib both w/ and w/o _frozen_importlib."""
fresh = ('importlib',) if '.' in module_name else ()
frozen = support.import_fresh_module(module_name)
source = support.import_fresh_module(module_name, fresh=fresh,
blocked=('_frozen_importlib',))
return frozen, source
示例5: test_main
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import import_fresh_module [as 别名]
def test_main(module=None):
# When invoked without a module, runs the Python ET tests by loading pyET.
# Otherwise, uses the given module as the ET.
global pyET
pyET = import_fresh_module('xml.etree.ElementTree',
blocked=['_elementtree'])
if module is None:
module = pyET
global ET
ET = module
test_classes = [
ModuleTest,
ElementSlicingTest,
BasicElementTest,
BadElementTest,
BadElementPathTest,
ElementTreeTest,
IOTest,
ParseErrorTest,
XIncludeTest,
ElementTreeTypeTest,
ElementFindTest,
ElementIterTest,
TreeBuilderTest,
XMLParserTest,
XMLPullParserTest,
BugsTest,
]
# These tests will only run for the pure-Python version that doesn't import
# _elementtree. We can't use skipUnless here, because pyET is filled in only
# after the module is loaded.
if pyET is not ET:
test_classes.extend([
NoAcceleratorTest,
])
try:
# XXX the C module should give the same warnings as the Python module
with CleanContext(quiet=(pyET is not ET)):
support.run_unittest(*test_classes)
finally:
# don't interfere with subsequent tests
ET = pyET = None