| Total Complexity | 9 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from lagom.util.functional import arity, FunctionCollection |
||
| 4 | |||
| 5 | |||
| 6 | def _func_a(): |
||
| 7 | pass |
||
| 8 | |||
| 9 | |||
| 10 | def _func_b(): |
||
| 11 | pass |
||
| 12 | |||
| 13 | |||
| 14 | @pytest.mark.parametrize( |
||
| 15 | "test_func,expected_arity", |
||
| 16 | [(lambda: 0, 0), (lambda x: x, 1), (lambda x, y: x + y, 2)], |
||
| 17 | ) |
||
| 18 | def test_we_can_get_arity_from_functions(test_func, expected_arity: int): |
||
| 19 | assert arity(test_func) == expected_arity |
||
| 20 | |||
| 21 | |||
| 22 | def test_function_collections_are_the_same_if_they_have_the_same_functions(): |
||
| 23 | assert FunctionCollection(_func_a, _func_b) == FunctionCollection(_func_a, _func_b) |
||
| 24 | |||
| 25 | |||
| 26 | def test_function_collections_have_equality_to_a_list_of_those_functions(): |
||
| 27 | assert FunctionCollection(_func_a, _func_b) == [_func_a, _func_b] |
||
| 28 | |||
| 29 | |||
| 30 | def test_function_collections_are_iterable(): |
||
| 31 | collected_funcs = [func for func in FunctionCollection(_func_a, _func_b)] |
||
| 32 | assert collected_funcs == [_func_a, _func_b] |
||
| 33 |