Пример #1
0
    def test_args_call_pos (self):
        assert _args(isstring)()
        assert _args(isstring)('dharma')
        assert _args(isstring)('dharma', 'miles')

        assert not _args(isstring)(4, "bad robot!")

        assert _and(_args(isstring),
                    _args(_not(isempty)))('jack', 'sawyer')
        assert not _and(_args(isstring),
                        _args(_not(isempty)))('jack', 'sawyer', '')
Пример #2
0
    def test_not (self):
        # no predicates
        assert _not()(True)

        # single predicate
        assert _not(isfalse)(True)
        assert _not(istrue)(False)
        assert not _not(isempty)('')

        # multiple predicates
        assert _not(isfalse, isstring)(True)
        assert _not(istrue, isstring)(False)
        assert not _not(isempty, isfalse)('')
        assert not _not(istrue, isstring)(True)
Пример #3
0
 def test_short_circuit (self):
     assert not _and(false, fail)()
     assert _or(true, fail)()
     assert not _not(true, fail)()
Пример #4
0
 def test_composition (self):
     assert not _and(_not(isstring), _or(isempty, isatom))('')
     assert _and(_not(isstring), _or(isempty, isatom))(())
     assert _and(_not(isstring), _or(isempty, isatom))(42)