def test_apply (self):
        # args
        assert _apply(isint)([42,])
        assert _apply(_all(isstring))(['jack', 'sawyer'])
        assert _zip(isint, _apply(_all(isstring)))(42, ['jack', 'sawyer'])

        # args + kwargs
        assert _apply(_npos(exactly=2)([42, "bad robot!"],
                                       {'jack': 4, 'kate': 15}))
        assert _apply(_nkw(exactly=2)([42, "bad robot!"],
                                      {'jack': 4, 'kate': 15}))
        assert _apply(_nargs(exactly=4)([42, "bad robot!"],
                                        {'jack': 4, 'kate': 15}))

        # recursive (yeah, it makes my brain hurt, too...) It's
        # actually pretty simple, though...  It's equivalent to
        # _and(isstring)(chain(people)) (in other words, it's a
        # completely contrived example which is much more cleanly
        # solved in another way! :-))

        # apply `isstring` to each element in an iterable. I.e.,
        # ``_apply(_all(isstring))(['jack', 'hurley'])`` is equivalent
        # to ``_all(isstring)('jack', 'hurley')
        all_strings = _apply(_all(isstring))

        # make two groups of people, then combine them
        group_1 = ['jack', 'sawyer']
        group_2 = ['kate', 'hurley']
        people = (group_1, group_2)

        assert _apply(_zip(all_strings, all_strings))(people)
 def test_apply_unexpected_kwargs (self):
     _apply(isstring)(["bad robot!"], {'jack': 4, 'kate': 15})
 def test_apply_too_many_args_for_predicate (self):
     _apply(isint)([23, 42])
 def test_apply_noniterable (self):
     # this doesn't do what you think...
     _apply(isint)(42)