-
-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathtest_gather.py
More file actions
43 lines (36 loc) · 1.01 KB
/
test_gather.py
File metadata and controls
43 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import anyio
import pytest
from returns.future import FutureResult
from returns.io import IOResult
from returns.methods import gather
from returns.result import Result
async def _helper_func1() -> str:
return 'successful function'
async def _helper_func2() -> str:
return 'failed function'
@pytest.mark.parametrize(
('containers', 'expected'),
[
(
(
FutureResult.from_value(1),
FutureResult.from_failure(None),
),
(IOResult.from_value(1), IOResult.from_failure(None)),
),
((), ()),
(
(
_helper_func1(),
_helper_func2(),
),
(
IOResult.from_result(Result.from_value('successful function')),
IOResult.from_result(Result.from_failure('failed function')),
),
),
],
)
def test_gather(containers, expected):
"""Test partition function."""
assert anyio.run(gather, containers) == expected