Example #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
Example #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()
Example #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()
Example #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
Example #5
0
def test_zip_none():
    future = f_zip()
    assert future.result() == ()
    assert "ZipTuple0" in repr(future)
Example #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")
Example #7
0
def test_zip_two():
    future = f_zip(f_return("a"), f_return("b"))
    assert future.result() == ("a", "b")
Example #8
0
def test_zip_single():
    value = "foobar"
    future = f_zip(f_return(value))
    assert future.result() == (value, )
    assert "ZipTuple1" in repr(future)
Example #9
0
def test_zip_error():
    with pytest.raises(TypeError):
        f_zip("a", "b", "c")