当前位置: 首页>>代码示例>>Python>>正文


Python test_support.ResourceDenied方法代码示例

本文整理汇总了Python中test.test_support.ResourceDenied方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.ResourceDenied方法的具体用法?Python test_support.ResourceDenied怎么用?Python test_support.ResourceDenied使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.test_support的用法示例。


在下文中一共展示了test_support.ResourceDenied方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runtest_inner

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import ResourceDenied [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 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:42,代码来源:regrtest.py

示例2: runtest_inner

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import ResourceDenied [as 别名]
def runtest_inner(test, generate, verbose, quiet,
                     testdir=None, huntrleaks=False, junit_xml_dir=None):
    test_support.unload(test)
    if not testdir:
        testdir = findtestdir()
    outputdir = os.path.join(testdir, "output")
    outputfile = os.path.join(outputdir, test)
    if verbose:
        cfp = None
    else:
        cfp = cStringIO.StringIO()

    try:
        save_stdout = sys.stdout
        if junit_xml_dir:
            from test.junit_xml import Tee, write_direct_test
            indirect_test = None
            save_stderr = sys.stderr
            sys.stdout = stdout = Tee(sys.stdout)
            sys.stderr = stderr = Tee(sys.stderr)
        try:
            if cfp:
                sys.stdout = cfp
                print test              # Output file starts with test name
            if test.startswith('test.'):
                abstest = test
            else:
                # Always import it from the test package
                abstest = 'test.' + test
            start = time.time()
            the_package = __import__(abstest, globals(), locals(), [])
            the_module = getattr(the_package, test)
            # Most tests run to completion simply as a side-effect of
            # being imported.  For the benefit of tests that can't run
            # that way (like test_threaded_import), 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()
            elif junit_xml_dir:
                write_direct_test(junit_xml_dir, abstest, time.time() - start,
                                  stdout=stdout.getvalue(),
                                  stderr=stderr.getvalue())
            if huntrleaks:
                dash_R(the_module, test, indirect_test, huntrleaks)
        finally:
            sys.stdout = save_stdout
            if junit_xml_dir:
                sys.stderr = save_stderr
    except test_support.ResourceDenied, msg:
        if not quiet:
            print test, "skipped --", msg
            sys.stdout.flush()
        if junit_xml_dir:
            write_direct_test(junit_xml_dir, abstest, time.time() - start,
                              'skipped', sys.exc_info(),
                              stdout=stdout.getvalue(),
                              stderr=stderr.getvalue())
        return -2 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:61,代码来源:regrtest.py


注:本文中的test.test_support.ResourceDenied方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。