예제 #1
0
def test_future_error():
    p = Promise()
    p.setError("woops")
    f = p.future()
    assert f.hasError() is True
    assert f.error() == "woops"
    try:
        f.value()
    except RuntimeError:
        pass
예제 #2
0
def test_future_andthen_error():
    global called
    called = False

    def callback(v):
        global called
        called = True
        assert False

    p = Promise()
    f = p.future()
    f2 = f.andThen(callback)
    p.setError("errlol")
    f2.wait(1000)
    assert f2.isFinished()
    assert f2.error() == "errlol"
    time.sleep(0.1)
    assert not called