def decorator(cls): if meta: return_cls, target_cls = _get_meta(cls) else: return_cls = target_cls = cls _wrap_setattr(target_cls, regex, macher, permisive(action)) return return_cls
def test_examples5(): func = lambda x=10, /, y=20, *, z=30: x * y + z assert 32 == permisive(func)(1, 2) assert 13 == permisive(func)(z=3, y=1) assert 230 == permisive(func)()
def test_examples4(): func = lambda x, /, y, *, z: x * y + z assert 5 == permisive(func)(1, 2, 3, 4, 5) == 5 assert 5 == permisive(func)(z=3, b=200, y=1, x=2, a=100) == 5
def test_examples3(): func = lambda x, **kw: x * sum(kw.values()) assert 45 == permisive(func)(3, kw=dict(a=4, b=5, c=6))
def test_examples2(): func = lambda x, *ar: x * sum(ar) assert 45 == permisive(func)(3, ar=(4, 5, 6))
def test_examples1(): func = lambda x, /, y, *, z: x * y + z assert 5 == permisive(func)(1, 2, 3) assert 5 == permisive(func)(z=3, y=1, x=2) assert 7 == permisive(func)(3, 1, y=2)