Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from curio import sleep |
||
2 | |||
3 | from async_btree import FAILURE, parallele |
||
4 | |||
5 | |||
6 | async def a_func(): |
||
7 | await sleep(1) |
||
8 | return 'a' |
||
9 | |||
10 | |||
11 | async def b_func(): |
||
12 | await sleep(3) |
||
13 | return 'b' |
||
14 | |||
15 | |||
16 | async def failure_func(): |
||
17 | await sleep(2) |
||
18 | return FAILURE |
||
19 | |||
20 | |||
21 | def test_parallele(kernel): |
||
22 | assert kernel.run(parallele(children=[a_func])) |
||
23 | assert kernel.run(parallele(children=[a_func, b_func])) |
||
24 | assert not kernel.run(parallele(children=[a_func, b_func, failure_func])) |
||
25 | assert kernel.run( |
||
26 | parallele(children=[a_func, b_func, failure_func], succes_threshold=2) |
||
27 | ) |
||
28 |