Passed
Pull Request — master (#3)
by Guibert
53s
created

test_leaf   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 18
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A test_action_with_exception_is_falsy() 0 5 1
A test_action_results() 0 5 1
A test_condition() 0 10 1
1
from curio import run
2
3
from libellule.control_flow.leaf import action, condition
4
5
6
def test_condition():
7
    async def target_test(value):
8
        return value
9
10
    assert run(
11
        condition(target_test, value=True)
12
    )  # pylint: disable=unexpected-keyword-arg
13
14
    assert not run(
15
        condition(target_test, value=False)
16
    )  # pylint: disable=unexpected-keyword-arg
17
18
19
def test_action_with_exception_is_falsy():
20
    async def generate_exception():
21
        raise Exception("Bing!")
22
23
    assert not run(action(generate_exception))
24
25
26
def test_action_results():
27
    async def compute(a, b):
28
        return a + b
29
30
    assert run(action(compute, a=1, b=1)) == 2
31