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


Python Promise.isFulfilled方法代码示例

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


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

示例1: test_list_promise_if

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [as 别名]
def test_list_promise_if():
    p1 = Promise()
    p1.fulfill(5)
    p2 = Promise()
    p2.fulfill(10)
    pl = listPromise(p1, p2)
    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,代码行数:15,代码来源:TestExtraFeatures.py

示例2: test_3_2_6_3_if_rejected

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [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

示例3: test_3_2_6_3_when_fulfilled

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [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

示例4: test_dict_promise_if

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [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

示例5: test_get_if

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [as 别名]
def test_get_if():
    p1 = Promise()
    p1.fulfill(5)
    v = p1.get()
    assert p1.isFulfilled()
    assert_equals(5, v)
开发者ID:LuminosoInsight,项目名称:aplus,代码行数:8,代码来源:TestExtraFeatures.py

示例6: test_wait_if

# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import isFulfilled [as 别名]
def test_wait_if():
    p1 = Promise()
    p1.fulfill(5)
    p1.wait()
    assert p1.isFulfilled()
开发者ID:LuminosoInsight,项目名称:aplus,代码行数:7,代码来源:TestExtraFeatures.py


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