本文整理汇总了Python中lancelot.Spec.raise_index_error方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.raise_index_error方法的具体用法?Python Spec.raise_index_error怎么用?Python Spec.raise_index_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lancelot.Spec
的用法示例。
在下文中一共展示了Spec.raise_index_error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: atomic_raise_behaviour
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import raise_index_error [as 别名]
def atomic_raise_behaviour():
''' should_raise() and should_not_raise() are the only
"atomic" parts that require test assertions. All other
functionality can be bootstrap-specified using these methods. '''
spec1 = Spec(dont_raise_index_error)
try:
spec1.dont_raise_index_error().should_raise(IndexError)
assert False
except UnmetSpecification:
# UnmetSpecification because no IndexError is raised
pass
spec2 = Spec(raise_index_error)
try:
spec2.raise_index_error().should_not_raise(IndexError)
assert False
except UnmetSpecification:
# UnmetSpecification because an IndexError is raised
pass
spec2 = Spec(raise_index_error)
try:
spec2.raise_index_error().should_raise(ValueError)
assert False
except IndexError:
# Not UnmetSpecification because IndexError is raised, not ValueError
pass