| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |