本文整理汇总了Python中importlib.machinery.SourceFileLoader.run_test方法的典型用法代码示例。如果您正苦于以下问题:Python SourceFileLoader.run_test方法的具体用法?Python SourceFileLoader.run_test怎么用?Python SourceFileLoader.run_test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类importlib.machinery.SourceFileLoader
的用法示例。
在下文中一共展示了SourceFileLoader.run_test方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SourceFileLoader
# 需要导入模块: from importlib.machinery import SourceFileLoader [as 别名]
# 或者: from importlib.machinery.SourceFileLoader import run_test [as 别名]
# same name, which leads to a test_name.py and test_name.so
# So we have to do it manually, given the full path
# Slightly different, depending on the test type
if test_ext == ".py":
m = SourceFileLoader(test_name, full_path).load_module()
else:
m = ExtensionFileLoader(test_name, full_path).load_module()
# Actually run the test, watching for exceptions
try:
# Run the test in the module
ret = m.run_test()
except Exception as e:
# Printing to pulsar output here so that it doesn't get
# interleaved with python's output
out = pulsar.get_global_output()
out.output("\n")
out.output("!!! Caught unhandled exception inside a test\n")
out.output(traceback.format_exc())
out.output("\n")
out.flush()
ret = -1
# Failure is signaled via non-zero exit value
exit(ret)