Skip to content

Commit

Permalink
test flatmap with an empty stream
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Nov 8, 2024
1 parent 2ee054c commit f989795
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fixlib/test/asynchronous/stream_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def count_invoked_fn(x: int) -> int:
assert await example_stream().map(sync_fn).collect() == [10, 8, 6, 4, 2]
assert await example_stream().map(async_fn).collect() == [10, 8, 6, 4, 2]
# The function will wait depending on the streamed value.
# Since we start from biggest to smallest, the result will be reversed
# Since we start from biggest to smallest, the result should be reversed
# High chance of being flaky, since it relies on timing.
assert await example_stream().map(async_fn, task_limit=100, ordered=False).collect() == [2, 4, 6, 8, 10]
# All items are processed in parallel, while the order is preserved.
Expand Down Expand Up @@ -88,6 +88,10 @@ async def async_gen(x: int) -> AsyncIterator[int]:

assert await example_stream().flatmap(sync_gen).collect() == [10, 10, 8, 8, 6, 6, 4, 4, 2, 2]
assert await example_stream().flatmap(async_gen).collect() == [10, 10, 8, 8, 6, 6, 4, 4, 2, 2]
assert await Stream.empty().flatmap(sync_gen).collect() == []
assert await Stream.empty().flatmap(async_gen).collect() == []
assert await Stream.iterate([]).flatmap(sync_gen).collect() == []
assert await Stream.iterate([]).flatmap(async_gen).collect() == []


async def test_take() -> None:
Expand Down

0 comments on commit f989795

Please sign in to comment.