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


Python Promise.isPending方法代码示例

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


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

示例1: test_3_2_6_3_when_rejected

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isPending [as 别名]
def test_3_2_6_3_when_rejected():
    """
    Testing return of pending promises to make
    sure they are properly chained.

    This covers the case where the root promise
    is rejected after the chaining is defined.
    """

    p1 = Promise()
    pending = Promise()
    pr = p1.then(None, lambda r: pending)
    assert pending.isPending()
    assert pr.isPending()
    p1.reject("Error")
    pending.fulfill(10)
    assert pending.isFulfilled()
    assert_equals(10, pending.value)
    assert pr.isFulfilled()
    assert_equals(10, pr.value)

    p2 = Promise()
    bad = Promise()
    pr = p2.then(None, lambda r: bad)
    assert bad.isPending()
    assert pr.isPending()
    p2.reject("Error")
    bad.reject("Assertion")
    assert bad.isRejected()
    assert_equals("Assertion", bad.reason)
    assert pr.isRejected()
    assert_equals("Assertion", pr.reason)
开发者ID:alin-luminoso,项目名称:aplus,代码行数:34,代码来源:TestSuite.py

示例2: test_list_promise_when

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isPending [as 别名]
def test_list_promise_when():
    p1 = Promise()
    p2 = Promise()
    pl = listPromise(p1, p2)
    assert p1.isPending()
    assert p2.isPending()
    assert pl.isPending()
    p1.fulfill(5)
    assert p1.isFulfilled()
    assert p2.isPending()
    assert pl.isPending()
    p2.fulfill(10)
    assert p1.isFulfilled()
    assert p2.isFulfilled()
    assert pl.isFulfilled()
    assert_equals(5, p1.value)
    assert_equals(10, p2.value)
    assert_equals(5, pl.value[0])
    assert_equals(10, pl.value[1])
开发者ID:LuminosoInsight,项目名称:aplus,代码行数:21,代码来源:TestExtraFeatures.py

示例3: test_dict_promise_if

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isPending [as 别名]
def test_dict_promise_if():
    p1 = Promise()
    p2 = Promise()
    d = {"a": p1, "b": p2}
    pd = dictPromise(d)
    assert p1.isPending()
    assert p2.isPending()
    assert pd.isPending()
    p1.fulfill(5)
    assert p1.isFulfilled()
    assert p2.isPending()
    assert pd.isPending()
    p2.fulfill(10)
    assert p1.isFulfilled()
    assert p2.isFulfilled()
    assert pd.isFulfilled()
    assert_equals(5, p1.value)
    assert_equals(10, p2.value)
    assert_equals(5, pd.value["a"])
    assert_equals(10, pd.value["b"])
开发者ID:LuminosoInsight,项目名称:aplus,代码行数:22,代码来源:TestExtraFeatures.py


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