本文整理汇总了Python中test.test_support.unload方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.unload方法的具体用法?Python test_support.unload怎么用?Python test_support.unload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.test_support
的用法示例。
在下文中一共展示了test_support.unload方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDown
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def tearDown(self):
if self.xx_created:
test_support.unload('xx')
# XXX on Windows the test leaves a directory
# with xx module in TEMP
super(BuildExtTestCase, self).tearDown()
示例2: testBlocker
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def testBlocker(self):
mname = "exceptions" # an arbitrary harmless builtin module
test_support.unload(mname)
sys.meta_path.append(ImportBlocker(mname))
self.assertRaises(ImportError, __import__, mname)
示例3: test_future1
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def test_future1(self):
test_support.unload('test_future1')
from test import test_future1
self.assertEqual(test_future1.result, 6)
示例4: test_future2
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def test_future2(self):
test_support.unload('test_future2')
from test import test_future2
self.assertEqual(test_future2.result, 6)
示例5: test_future3
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def test_future3(self):
test_support.unload('test_future3')
from test import test_future3
示例6: runtest_inner
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def runtest_inner(test, verbose, quiet, huntrleaks=False):
test_support.unload(test)
if verbose:
capture_stdout = None
else:
capture_stdout = StringIO.StringIO()
test_time = 0.0
refleak = False # True if the test leaked references.
try:
save_stdout = sys.stdout
try:
if capture_stdout:
sys.stdout = capture_stdout
if test.startswith('test.'):
abstest = test
else:
# Always import it from the test package
abstest = 'test.' + test
with saved_test_environment(test, verbose, quiet) as environment:
start_time = time.time()
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, test)
# Old tests run to completion simply as a side-effect of
# being imported. For tests based on unittest or doctest,
# explicitly invoke their test_main() function (if it exists).
indirect_test = getattr(the_module, "test_main", None)
if indirect_test is not None:
indirect_test()
if huntrleaks:
refleak = dash_R(the_module, test, indirect_test,
huntrleaks)
test_time = time.time() - start_time
finally:
sys.stdout = save_stdout
except test_support.ResourceDenied, msg:
if not quiet:
print test, "skipped --", msg
sys.stdout.flush()
return RESOURCE_DENIED, test_time
示例7: tearDown
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def tearDown(self):
# Get everything back to normal
if os.path.exists(_XX_MODULE_PATH):
test_support.unload('xx')
sys.path[:] = self.sys_path
# XXX on Windows the test leaves a directory
# with xx module in TEMP
shutil.rmtree(self.tmp_dir, os.name == 'nt' or
sys.platform == 'cygwin')
super(BuildExtTestCase, self).tearDown()
示例8: test_multiple_features
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def test_multiple_features(self):
test_support.unload("test.test_future5")
from test import test_future5
示例9: unload
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def unload(self, test):
pass
示例10: run_test
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import unload [as 别名]
def run_test(test, verbose, runner=None, capture=0):
"""
Run a single test.
test -- the name of the test
verbose -- if true, print more messages
"""
test_support.unload(test)
try:
m = load_module_from_name(test, path=sys.path)
# m = __import__(test, globals(), locals(), sys.path)
try:
suite = m.suite
if callable(suite):
suite = suite()
except AttributeError:
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
if runner is None:
runner = SkipAwareTextTestRunner(capture=capture) # verbosity=0)
return runner.run(suite)
except KeyboardInterrupt as v:
raise KeyboardInterrupt, v, sys.exc_info()[2]
except:
# raise
type, value = sys.exc_info()[:2]
msg = "test %s crashed -- %s : %s" % (test, type, value)
if verbose:
traceback.print_exc()
return msg