Skip to content

Commit

Permalink
Merge pull request #3 from TheArtur128/development for 2.1.1 version
Browse files Browse the repository at this point in the history
Code for 2.1.1 version
  • Loading branch information
emptybutton authored Jan 26, 2023
2 parents 8161bf7 + e18e298 commit e6d1cb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyhandling/branchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def on_condition(
condition_checker: factory_for[bool],
positive_condition_func: Callable,
*,
else_: Callable
else_: Callable = lambda *_, **__: None
) -> Callable:
"""
Function that implements the func choosing by condition.
Expand Down
12 changes: 12 additions & 0 deletions tests/test_branchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ def test_on_condition_by_numeric_functions(
)(input_number) == result


@mark.parametrize(
"is_positive_case, input_number, result",
[(True, 6, 8), (False, 6, None)]
)
def test_on_condition_with_default_else_(
is_positive_case: bool,
input_number: int | float,
result: Any
):
assert on_condition(lambda _: is_positive_case, lambda x: x + 2)(input_number) == result


@mark.parametrize(
"func, input_args, input_kwargs, result",
[
Expand Down

0 comments on commit e6d1cb4

Please sign in to comment.