def test_fn_info_with_regular_function(): def inc(x): return x + 1 info = u.fn_info(inc) assert info == { 'name': 'inc', 'module': 'test_utils', 'varargs': (), 'kargs': {} }
def test_fn_info_with_partial_of_partial(): def mult(*args): return t.reduce(lambda a, b: a * b, args) double = t.partial(mult, 2) quad = t.partial(double, 2) info = u.fn_info(quad) assert info == { 'name': 'mult', 'module': 'test_utils', 'varargs': (2, 2), 'kargs': {} }
def test_fn_info_with_partial(): def mult(x, y): return x * y double = t.partial(mult, 2) info = u.fn_info(double) assert info == { 'name': 'mult', 'module': 'test_utils', 'varargs': (), 'kargs': { 'x': 2 } }
def test_fn_info_with_curry(): @t.curry def mult(x, y): return x * y double = mult(2) assert double(2) == 4 info = u.fn_info(double) assert info == { 'name': 'mult', 'module': 'test_utils', 'varargs': (), 'kargs': { 'x': 2 } }
def test_fn_info_with_multiple_curries(): @t.curry def mult(a, b, c): return a * b * c double = mult(2) quad = double(2) info = u.fn_info(quad) assert info == { 'name': 'mult', 'module': 'test_utils', 'varargs': (), 'kargs': { 'a': 2, 'b': 2 } }