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


Python Promise.isRejected方法代码示例

本文整理汇总了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)
开发者ID:alin-luminoso,项目名称:aplus,代码行数:30,代码来源:TestSuite.py

示例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)
开发者ID:alin-luminoso,项目名称:aplus,代码行数:34,代码来源:TestSuite.py


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