2Tests for `concurrently`.
8from concurrently import concurrently
11def double(x: int) -> int:
13 Double a number, but with a random delay.
15 time.sleep(random.random() / 100)
19def test_handles_iterator() -> None:
21 Check the input is processed correctly when the input is an iterator.
23 result = set(concurrently(handler=double, inputs=range(10)))
39def test_handles_list() -> None:
41 Check the input is processed correctly when the input is a list.
43 result = set(concurrently(handler=double, inputs=[1, 3, 5, 7, 9, 11, 13]))
45 assert result == {(1, 2), (3, 6), (5, 10), (7, 14), (9, 18), (11, 22), (13, 26)}