def test_isbool(self): false1 = utils.isbool("123.45") false2 = utils.isbool("hey") true1 = utils.isbool("TRUE") true2 = utils.isbool("FALSE") self.assertFalse(false1) self.assertFalse(false2) self.assertTrue(true1) self.assertTrue(true2)
def not_(x): if not isbool(x): raise TypeError('`!` expected Boolean arguments, got `%s`' \ % type(x).__name__) if x: return false else: return true
def fold(self): s = [x for x, m in self.iteritems() if m > 0] if len(s): for val in s: if not isbool(val): raise TypeError('%s is not Boolean.' % _repr(val)) # TODO: can short circuit as soon as we get a true... but above we # check the types.. so we don't get the benefit. return todyna(any(s))
def and_(x, y): if not (isbool(x) and isbool(y)): raise TypeError('`&` expected Boolean arguments, got `%s` and `%s`' \ % (type(x).__name__, type(y).__name__)) return todyna(x and y)