def test_compose_threearg(self): append_exclamation_point = (functools.partial(func.flip(operator.add), "!")) make_hello = func.compose(str, self.add_to_hello, append_exclamation_point) self.assertEqual(make_hello(1), "Hello, 1!")
def test_flip(self): def myfunc(a, b): return (a, b) result = func.flip(myfunc)(1, 2) self.assertEqual(result, (2, 1))
def test_flip_with_more_args(self): def myfunc(a, b, c): return a, b, c result = func.flip(myfunc)(1, 2, 3) self.assertEqual(result, (2, 1, 3))