Beispiel #1
0
async def test_collect_all_reader_future_result(subtests):
    """Iterable for ``ReaderFutureResult`` and ``CollectAll``."""
    containers: List[Tuple[  # noqa: WPS234
        Iterable[ReaderFutureResult[int, str, NoDeps]],
        ReaderFutureResult[Sequence[int], str, NoDeps], ]] = [
            ([], ReaderFutureResult.from_value(())),
            (
                [ReaderFutureResult.from_value(1)],
                ReaderFutureResult.from_value((1, )),
            ),
            (
                [
                    ReaderFutureResult.from_value(1),
                    ReaderFutureResult.from_value(2),
                ],
                ReaderFutureResult.from_value((1, 2)),
            ),
            (
                [
                    ReaderFutureResult.from_failure('a'),
                    ReaderFutureResult.from_value(1),
                    ReaderFutureResult.from_value(2),
                ],
                ReaderFutureResult.from_value((1, 2)),
            ),
            (
                [
                    ReaderFutureResult.from_failure('a'),
                    ReaderFutureResult.from_failure('b'),
                ],
                ReaderFutureResult.from_value(()),
            ),
        ]
    for iterable, sequence in containers:
        with subtests.test(iterable=iterable, sequence=sequence):
            assert await ReaderFutureResult.from_iterable(
                iterable,
                CollectAll,
            )(...) == await sequence(...)
Beispiel #2
0
    Result.from_value(1),
    IO(1),
    IOResult.from_failure(1),
    IOResult.from_value(1),
    Maybe.from_value(1),
    Maybe.from_value(None),
    Maybe.from_optional(None),
    Future.from_value(1),
    FutureResult.from_value(1),
    FutureResult.from_failure(1),
    Reader.from_value(1),
    ReaderResult.from_value(1),
    ReaderResult.from_failure(1),
    ReaderIOResult.from_value(1),
    ReaderIOResult.from_failure(1),
    ReaderFutureResult.from_value(1),
    ReaderFutureResult.from_failure(1),
)


@pytest.mark.parametrize('container', _containers)
def test_assert_equal(container, anyio_backend_name: str):
    """Ensure that containers can be equal."""
    assert_equal(container, container, backend=anyio_backend_name)


@pytest.mark.parametrize('container', _containers)
def test_assert_equal_plugin(
    container,
    anyio_backend_name: str,
    returns: ReturnsAsserts,
Beispiel #3
0
def _use_success(inner_value: str) -> ReaderFutureResult[NoDeps, str, str]:
    return ReaderFutureResult.from_value('use success')
Beispiel #4
0
def _acquire_success() -> ReaderFutureResult[NoDeps, str, str]:
    return ReaderFutureResult.from_value('acquire success')