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


Python AssertionHelper.raises方法代码示例

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


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

示例1: throw

# 需要导入模块: from sure.old import AssertionHelper [as 别名]
# 或者: from sure.old.AssertionHelper import raises [as 别名]
    def throw(self, *args, **kw):
        _that = AssertionHelper(self.obj, with_args=self._callable_args, and_kwargs=self._callable_kw)

        if self.negative:
            msg = "{0} called with args {1} and kwargs {2} should " "not raise {3} but raised {4}"

            exc = args and args[0] or Exception
            try:
                self.obj(*self._callable_args, **self._callable_kw)
                return True
            except Exception as e:
                err = msg.format(self.obj, self._that._callable_args, self._that._callable_kw, exc, e)
                raise AssertionError(err)

        return _that.raises(*args, **kw)
开发者ID:CyrilRoelandteNovance,项目名称:sure,代码行数:17,代码来源:__init__.py

示例2: cool

# 需要导入模块: from sure.old import AssertionHelper [as 别名]
# 或者: from sure.old.AssertionHelper import raises [as 别名]
    def cool(self):
        _that = AssertionHelper(self.obj,
                     with_args=self._callable_args,
                     and_kwargs=self._callable_kw)
        if self.negative:
            try:
                return _that.raises(Exception)
            except AssertionError:
                raise AssertionError('The callable `{0}` was supposed to not be cool and throw an exception, but it is too cool for that'.format(self.obj.__name__))

        try:
            self.obj(*self._callable_args, **self._callable_kw)
        except Exception as e:
            raise AssertionError('The callable `{2}` should be cool but threw {0}: {1}'.format(
                e.__class__.__name__,
                str(e),
                self.obj.__name__
            ))

        return True
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:22,代码来源:__init__.py


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