本文整理汇总了Python中aplus.Promise.isRejected方法的典型用法代码示例。如果您正苦于以下问题:Python Promise.isRejected方法的具体用法?Python Promise.isRejected怎么用?Python Promise.isRejected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aplus.Promise
的用法示例。
在下文中一共展示了Promise.isRejected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_3_2_6_3_if_rejected
# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isRejected [as 别名]
def test_3_2_6_3_if_rejected():
"""
Testing return of pending promises to make
sure they are properly chained.
This covers the case where the root promise
is rejected before the chaining is defined.
"""
p1 = Promise()
p1.reject("Error")
pending = Promise()
pending.fulfill(10)
pr = p1.then(None, lambda r: pending)
assert pending.isFulfilled()
assert_equals(10, pending.value)
assert pr.isFulfilled()
assert_equals(10, pr.value)
p2 = Promise()
p2.reject("Error")
bad = Promise()
bad.reject("Assertion")
pr = p2.then(None, lambda r: bad)
assert bad.isRejected()
assert_equals("Assertion", bad.reason)
assert pr.isRejected()
assert_equals("Assertion", pr.reason)
示例2: test_3_2_6_3_when_fulfilled
# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isRejected [as 别名]
def test_3_2_6_3_when_fulfilled():
"""
Testing return of pending promises to make
sure they are properly chained.
This covers the case where the root promise
is fulfilled after the chaining is defined.
"""
p1 = Promise()
pending = Promise()
pf = p1.then(lambda r: pending)
assert pending.isPending()
assert pf.isPending()
p1.fulfill(10)
pending.fulfill(5)
assert pending.isFulfilled()
assert_equals(5, pending.value)
assert pf.isFulfilled()
assert_equals(5, pf.value)
p2 = Promise()
bad = Promise()
pr = p2.then(lambda r: bad)
assert bad.isPending()
assert pr.isPending()
p2.fulfill(10)
bad.reject("Error")
assert bad.isRejected()
assert_equals("Error", bad.reason)
assert pr.isRejected()
assert_equals("Error", pr.reason)