Beispiel #1
0
async def test_catch_one_with_error():
    xs = from_async_iterable(iter_error())
    result = []

    async def asend(value):
        log.debug("test_catch_one_with_error:asend(%s)", value)
        result.append(value)

    zs = catch_exception([xs])

    await run(zs, AsyncAnonymousObserver(asend))
    assert result == list(range(5))
Beispiel #2
0
async def test_retry():
    xs = from_async_iterable(iter_error())
    result = []

    async def asend(value):
        print("ASEND", value)
        log.debug("test_retry:asend(%s)", value)
        result.append(value)

    zs = catch_exception([xs])

    await run(zs, AsyncAnonymousObserver(asend))
    assert result == list(range(10))
Beispiel #3
0
async def test_concat_async():
    xs = from_async_iterable(asynciter())
    ys = from_iterable(range(5, 10))
    result = []

    async def asend(value):
        log.debug("test_concat_async:send(%s)", value)
        result.append(value)

    zs = concat(xs, ys)

    await run(zs, AsyncAnonymousObserver(asend))
    assert result == list(range(10))
async def test_async_iteration_inception() -> None:
    # iterable to async source to async iterator to async source
    obv = AsyncIteratorObserver()

    xs = AsyncObservable.from_iterable([1, 2, 3])
    await subscribe(xs, obv)
    ys = from_async_iterable(obv)
    result = []

    async for y in to_async_iterable(ys):
        result.append(y)

    assert result == [1, 2, 3]