예제 #1
0
def test_zip_error():
    error = RuntimeError("simulated error")
    f_a = f_return("a")
    f_b = f_return_error(error)
    f_c = f_return("c")
    future = f_zip(f_a, f_b, f_c)
    assert future.exception() is error
예제 #2
0
def test_zip_cancel():
    f_a = f_return("a")
    f_b = Future()
    f_c = Future()
    future = f_zip(f_a, f_b, f_c)

    future.cancel()

    assert f_b.cancelled()
    assert f_c.cancelled()
예제 #3
0
def test_zip_inner_cancel():
    f_a = f_return("a")
    f_b = Future()
    f_c = Future()
    future = f_zip(f_a, f_b, f_c)

    assert f_b.cancel()

    # Cancelling the inner future should cause the outer
    # future to also become cancelled, as well as the
    # other inner futures.
    assert f_c.cancelled()
    assert future.cancelled()
예제 #4
0
def test_zip_large():
    fs = [f_return(i) for i in range(0, 100000)]
    future = f_zip(*fs)
    result = future.result()
    assert result[0:5] == (0, 1, 2, 3, 4)
    assert len(result) == 100000
예제 #5
0
def test_zip_none():
    future = f_zip()
    assert future.result() == ()
    assert "ZipTuple0" in repr(future)
예제 #6
0
def test_zip_three():
    f_a = f_return("a")
    f_b = f_return("b")
    f_c = f_return("c")
    future = f_zip(f_a, f_b, f_c)
    assert future.result() == ("a", "b", "c")
예제 #7
0
def test_zip_two():
    future = f_zip(f_return("a"), f_return("b"))
    assert future.result() == ("a", "b")
예제 #8
0
def test_zip_single():
    value = "foobar"
    future = f_zip(f_return(value))
    assert future.result() == (value, )
    assert "ZipTuple1" in repr(future)
예제 #9
0
def test_zip_error():
    with pytest.raises(TypeError):
        f_zip("a", "b", "c")