refactor: add python generic helpers

- move catch and update_and_return_dict there
This commit is contained in:
Arthur Meyre
2021-11-04 15:16:27 +01:00
parent 39ad5bd894
commit fae89bd452
4 changed files with 61 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
"""Test file for common python helpers"""
from concrete.common.helpers.python_helpers import catch
def test_catch_failure():
"""Test case for when the function called with catch raises an exception."""
def f_fail():
return 1 / 0
assert catch(f_fail) is None
def test_catch():
"""Test case for catch"""
def f(*args, **kwargs):
return *args, dict(**kwargs)
assert catch(f, (1, 2, 3,), **{"one": 1, "two": 2, "three": 3}) == (
(1, 2, 3),
{"one": 1, "two": 2, "three": 3},
)