Passed
Pull Request — master (#4)
by Guibert
50s
created

tests.test_parallele.test_parallele()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nop 1
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