|
1 | 1 |
|
2 | 2 | import pytest |
3 | 3 |
|
| 4 | +import anyio |
4 | 5 | from returns.future import Future, FutureResult |
| 6 | +from returns.result import Result |
5 | 7 | from returns.io import IO, IOResult |
6 | 8 | from returns.methods import gather |
7 | 9 |
|
8 | 10 |
|
| 11 | +async def _helper_func1() -> str: |
| 12 | + return 'successful function' |
| 13 | + |
| 14 | + |
| 15 | +async def _helper_func2() -> str: |
| 16 | + return 'failed function' |
| 17 | + |
9 | 18 | @pytest.mark.parametrize(('containers', 'expected'), [ |
10 | 19 | ( |
11 | 20 | ( |
12 | | - Future.from_value(1), |
13 | | - FutureResult.from_value(2), |
| 21 | + FutureResult.from_value(1), |
14 | 22 | FutureResult.from_failure(None), |
15 | 23 | ), |
16 | | - (IO(1), IOResult.from_value(2), IOResult.from_failure(None)), |
| 24 | + (IOResult.from_value(1), IOResult.from_failure(None)), |
17 | 25 | ), |
18 | 26 | ((), ()), |
| 27 | + ( |
| 28 | + ( |
| 29 | + _helper_func1(), |
| 30 | + _helper_func2(), |
| 31 | + ), |
| 32 | + (IOResult.from_result(Result.from_value("successful function")), IOResult.from_result(Result.from_failure("failed function"))) |
| 33 | + ) |
19 | 34 | ]) |
20 | | -async def test_gather(containers, expected): |
| 35 | +def test_gather(containers, expected): |
21 | 36 | """Test partition function.""" |
22 | | - assert await gather(containers) == expected |
| 37 | + assert anyio.run(gather,containers) == expected |
0 commit comments