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


Python TestCase.failureException方法代码示例

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


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

示例1: wait_no_exception

# 需要导入模块: from testtools import TestCase [as 别名]
# 或者: from testtools.TestCase import failureException [as 别名]
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
    """Stops waiting on success."""
    start_time = time.time()
    if exc_matcher is not None:
        exc_class = boto.exception.BotoServerError

    if exc_class is None:
        exc_class = BaseException
    while True:
        result = None
        try:
            result = lfunction()
            LOG.info('No Exception in %d second',
                     time.time() - start_time)
            return result
        except exc_class as exc:
            if exc_matcher is not None:
                res = exc_matcher.match(exc)
                if res is not None:
                    LOG.info(res)
                    raise exc
        # Let the other exceptions propagate
        dtime = time.time() - start_time
        if dtime > CONF.boto.build_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(CONF.boto.build_interval)
开发者ID:Grindizer,项目名称:tempest,代码行数:29,代码来源:wait.py

示例2: state_wait

# 需要导入模块: from testtools import TestCase [as 别名]
# 或者: from testtools.TestCase import failureException [as 别名]
def state_wait(lfunction, final_set=set(), valid_set=None):
    # TODO(afazekas): evaluate using ABC here
    if not isinstance(final_set, set):
        final_set = set((final_set,))
    if not isinstance(valid_set, set) and valid_set is not None:
        valid_set = set((valid_set,))
    start_time = time.time()
    old_status = status = lfunction()
    while True:
        if status != old_status:
            LOG.info('State transition "%s" ==> "%s" %d second', old_status,
                     status, time.time() - start_time)
        if status in final_set:
            return status
        if valid_set is not None and status not in valid_set:
            return status
        dtime = time.time() - start_time
        if dtime > CONF.boto.build_timeout:
            raise TestCase.failureException("State change timeout exceeded!"
                                            '(%ds) While waiting'
                                            'for %s at "%s"' %
                                            (dtime, final_set, status))
        time.sleep(CONF.boto.build_interval)
        old_status = status
        status = lfunction()
开发者ID:Grindizer,项目名称:tempest,代码行数:27,代码来源:wait.py

示例3: wait_exception

# 需要导入模块: from testtools import TestCase [as 别名]
# 或者: from testtools.TestCase import failureException [as 别名]
def wait_exception(lfunction):
    """Returns with the exception or raises one."""
    start_time = time.time()
    while True:
        try:
            lfunction()
        except BaseException as exc:
            LOG.info('Exception in %d second',
                     time.time() - start_time)
            return exc
        dtime = time.time() - start_time
        if dtime > CONF.boto.build_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(CONF.boto.build_interval)
开发者ID:Grindizer,项目名称:tempest,代码行数:17,代码来源:wait.py

示例4: re_search_wait

# 需要导入模块: from testtools import TestCase [as 别名]
# 或者: from testtools.TestCase import failureException [as 别名]
def re_search_wait(lfunction, regexp):
    """Stops waiting on success."""
    start_time = time.time()
    while True:
        text = lfunction()
        result = re.search(regexp, text)
        if result is not None:
            LOG.info('Pattern "%s" found in %d second in "%s"',
                     regexp,
                     time.time() - start_time,
                     text)
            return result
        dtime = time.time() - start_time
        if dtime > CONF.boto.build_timeout:
            raise TestCase.failureException('Pattern find timeout exceeded!'
                                            '(%ds) While waiting for'
                                            '"%s" pattern in "%s"' %
                                            (dtime, regexp, text))
        time.sleep(CONF.boto.build_interval)
开发者ID:Grindizer,项目名称:tempest,代码行数:21,代码来源:wait.py


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