mirror of
https://github.com/zama-ai/concrete.git
synced 2026-04-17 03:00:54 -04:00
refactor: add python generic helpers
- move catch and update_and_return_dict there
This commit is contained in:
24
tests/common/helpers/test_python_helpers.py
Normal file
24
tests/common/helpers/test_python_helpers.py
Normal 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},
|
||||
)
|
||||
Reference in New Issue
Block a user