Skip to content

Commit e6d1cb4

Browse files
authored
Merge pull request #3 from TheArtur128/development for 2.1.1 version
Code for 2.1.1 version
2 parents 8161bf7 + e18e298 commit e6d1cb4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pyhandling/branchers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def on_condition(
207207
condition_checker: factory_for[bool],
208208
positive_condition_func: Callable,
209209
*,
210-
else_: Callable
210+
else_: Callable = lambda *_, **__: None
211211
) -> Callable:
212212
"""
213213
Function that implements the func choosing by condition.

tests/test_branchers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ def test_on_condition_by_numeric_functions(
255255
)(input_number) == result
256256

257257

258+
@mark.parametrize(
259+
"is_positive_case, input_number, result",
260+
[(True, 6, 8), (False, 6, None)]
261+
)
262+
def test_on_condition_with_default_else_(
263+
is_positive_case: bool,
264+
input_number: int | float,
265+
result: Any
266+
):
267+
assert on_condition(lambda _: is_positive_case, lambda x: x + 2)(input_number) == result
268+
269+
258270
@mark.parametrize(
259271
"func, input_args, input_kwargs, result",
260272
[

0 commit comments

Comments
 (0)