Esempio n. 1
0
def test_map_error():
    map_in = f_return(0)

    # This one should fail...
    mapped = f_map(map_in, div10)

    # Now map it through an error handler
    mapped = f_map(mapped, error_fn=str)

    result = mapped.result()
    assert "division" in result
Esempio n. 2
0
def test_map():
    sem = Semaphore(0)
    with Executors.thread_pool() as exc:
        # This future cannot possibly proceed until we unblock the semaphore.
        f = exc.submit(sem.acquire)
        f = f_proxy(f)

        # If bug #278 exists, we will hang here indefinitely.
        f = f_map(f, lambda _: 123)

        # If bug is fixed, future is still not evaluated.
        # Let it proceed now.
        sem.release()
        assert f.result() == 123
Esempio n. 3
0
def test_map_error():
    with pytest.raises(TypeError):
        f_map("a", lambda x: x)

    with pytest.raises(TypeError):
        f_map(future="a", fn=lambda x: x)
Esempio n. 4
0
def test_map_nothing():
    map_in = f_return(10)
    mapped = f_map(map_in)
    assert mapped.result() == 10
Esempio n. 5
0
def test_map():
    map_in = f_return(10)
    mapped = f_map(map_in, div10)
    assert mapped.result() == 1