def test_nkw_between_both (self):
        assert _nkw(atleast=1, atmost=2)(4, sawyer=8)
        assert _nkw(atleast=1, atmost=3)(4, sawyer=8, hurley=15)
        assert _nkw(atleast=2, atmost=3)(4, sawyer=8, hurley=15)
        assert _nkw(atleast=2, atmost=3)(4, 8, hurley=15, kate=16, locke=23)

        assert not _nkw(atleast=1, atmost=2)(4, 8, hurley=15, kate=16, locke=23)
    def test_nkw_exactly_both (self):
        assert _nkw(exactly=2)(4, sawyer=8, hurley=15)

        assert not _nkw(exactly=0)(4, sawyer=8)
        assert not _nkw(exactly=1)(4)
        assert not _nkw(exactly=1)(4, sawyer=8, hurley=15)
        assert not _nkw(exactly=3)(4, sawyer=8)
    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_nkw_between_kw (self):
        assert _nkw(atleast=0, atmost=1)()
        assert _nkw(atleast=0, atmost=1)(jack=4)
        assert _nkw(atleast=1, atmost=2)(jack=4, sawyer=8)
        assert _nkw(atleast=1, atmost=3)(jack=4, sawyer=8)
        assert _nkw(atleast=2, atmost=3)(jack=4, sawyer=8)
        assert _nkw(atleast=2, atmost=3)(jack=4, sawyer=8, hurley=15)

        assert not _nkw(atleast=1, atmost=2)()
        assert not _nkw(atleast=1, atmost=2)(jack=4, sawyer=8, hurley=15)
    def test_nkw_exactly_kw (self):
        assert _nkw(exactly=0)()
        assert _nkw(exactly=1)(jack=4)
        assert _nkw(exactly=2)(jack=4, sawyer=8)

        assert not _nkw(exactly=0)(jack=4)
        assert not _nkw(exactly=1)()
        assert not _nkw(exactly=1)(jack=4, sawyer=8)
        assert not _nkw(exactly=2)(jack=4)
    def test_nkw_atleast_kw (self):
        assert _nkw(atleast=0)()
        assert _nkw(atleast=0)(jack=4)
        assert _nkw(atleast=0)(jack=4, sawyer=8)
        assert _nkw(atleast=1)(jack=4, sawyer=8)
        assert _nkw(atleast=2)(jack=4, sawyer=8)

        assert not _nkw(atleast=1)()
        assert not _nkw(atleast=2)(1)
    def test_nkw_atmost_both (self):
        assert _nkw(atmost=0)(4)
        assert _nkw(atmost=2)(4)
        assert _nkw(atmost=2)(4, sawyer=8)
        assert _nkw(atmost=2)(4, sawyer=8, hurley=15)

        assert not _nkw(atmost=0)(4, sawyer=8)
        assert not _nkw(atmost=1)(4, sawyer=8, hurley=15)
 def test_nkw_bad_negative (self):
     _nkw(atleast=-1)
 def test_nkw_bad_spec (self):
     _nkw(atleast=1, exactly=2)